forked from python/python-docs-tr
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path3.3.html
More file actions
2764 lines (2721 loc) · 321 KB
/
3.3.html
File metadata and controls
2764 lines (2721 loc) · 321 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<meta property="og:title" content="What’s New In Python 3.3" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://docs.python.org/3/whatsnew/3.3.html" />
<meta property="og:site_name" content="Python documentation" />
<meta property="og:description" content="This article explains the new features in Python 3.3, compared to 3.2. Python 3.3 was released on September 29, 2012. For full details, see the changelog. Summary – Release highlights: New syntax f..." />
<meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
<meta property="og:image:alt" content="Python documentation" />
<meta name="description" content="This article explains the new features in Python 3.3, compared to 3.2. Python 3.3 was released on September 29, 2012. For full details, see the changelog. Summary – Release highlights: New syntax f..." />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<meta name="theme-color" content="#3776ab" />
<title>What’s New In Python 3.3 — Python 3.11.5 belgelendirmesi</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?digest=b37c26da2f7529d09fe70b41c4b2133fe4931a90" />
<link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css" />
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script src="../_static/translations.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Python 3.11.5 belgelendirmesi içinde ara"
href="../_static/opensearch.xml"/>
<link rel="author" title="Bu belgeler hakkında" href="../about.html" />
<link rel="index" title="Dizin" href="../genindex.html" />
<link rel="search" title="Ara" href="../search.html" />
<link rel="copyright" title="Telif Hakkı" href="../copyright.html" />
<link rel="next" title="What’s New In Python 3.2" href="3.2.html" />
<link rel="prev" title="What’s New In Python 3.4" href="3.4.html" />
<link rel="canonical" href="https://docs.python.org/3/whatsnew/3.3.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
<script type="text/javascript" src="../_static/search-focus.js"></script>
<script type="text/javascript" src="../_static/themetoggle.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<nav class="nav-content" role="navigation">
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<span class="nav-items-wrapper">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<span class="version_switcher_placeholder"></span>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>
</svg>
<input placeholder="Hızlı Arama" aria-label="Hızlı Arama" type="search" name="q" />
<input type="submit" value="Git"/>
</form>
</span>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label>
<div>
<h3><a href="../contents.html">İçindekiler</a></h3>
<ul>
<li><a class="reference internal" href="#">What’s New In Python 3.3</a><ul>
<li><a class="reference internal" href="#summary-release-highlights">Summary – Release highlights</a></li>
<li><a class="reference internal" href="#pep-405-virtual-environments">PEP 405: Virtual Environments</a></li>
<li><a class="reference internal" href="#pep-420-implicit-namespace-packages">PEP 420: Implicit Namespace Packages</a></li>
<li><a class="reference internal" href="#pep-3118-new-memoryview-implementation-and-buffer-protocol-documentation">PEP 3118: New memoryview implementation and buffer protocol documentation</a><ul>
<li><a class="reference internal" href="#features">Features</a></li>
<li><a class="reference internal" href="#api-changes">API changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pep-393-flexible-string-representation">PEP 393: Flexible String Representation</a><ul>
<li><a class="reference internal" href="#functionality">Functionality</a></li>
<li><a class="reference internal" href="#performance-and-resource-usage">Performance and resource usage</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pep-397-python-launcher-for-windows">PEP 397: Python Launcher for Windows</a></li>
<li><a class="reference internal" href="#pep-3151-reworking-the-os-and-io-exception-hierarchy">PEP 3151: Reworking the OS and IO exception hierarchy</a></li>
<li><a class="reference internal" href="#pep-380-syntax-for-delegating-to-a-subgenerator">PEP 380: Syntax for Delegating to a Subgenerator</a></li>
<li><a class="reference internal" href="#pep-409-suppressing-exception-context">PEP 409: Suppressing exception context</a></li>
<li><a class="reference internal" href="#pep-414-explicit-unicode-literals">PEP 414: Explicit Unicode literals</a></li>
<li><a class="reference internal" href="#pep-3155-qualified-name-for-classes-and-functions">PEP 3155: Qualified name for classes and functions</a></li>
<li><a class="reference internal" href="#pep-412-key-sharing-dictionary">PEP 412: Key-Sharing Dictionary</a></li>
<li><a class="reference internal" href="#pep-362-function-signature-object">PEP 362: Function Signature Object</a></li>
<li><a class="reference internal" href="#pep-421-adding-sys-implementation">PEP 421: Adding sys.implementation</a><ul>
<li><a class="reference internal" href="#simplenamespace">SimpleNamespace</a></li>
</ul>
</li>
<li><a class="reference internal" href="#using-importlib-as-the-implementation-of-import">Using importlib as the Implementation of Import</a><ul>
<li><a class="reference internal" href="#new-apis">New APIs</a></li>
<li><a class="reference internal" href="#visible-changes">Visible Changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#other-language-changes">Other Language Changes</a></li>
<li><a class="reference internal" href="#a-finer-grained-import-lock">A Finer-Grained Import Lock</a></li>
<li><a class="reference internal" href="#builtin-functions-and-types">Builtin functions and types</a></li>
<li><a class="reference internal" href="#new-modules">New Modules</a><ul>
<li><a class="reference internal" href="#faulthandler">faulthandler</a></li>
<li><a class="reference internal" href="#ipaddress">ipaddress</a></li>
<li><a class="reference internal" href="#lzma">lzma</a></li>
</ul>
</li>
<li><a class="reference internal" href="#improved-modules">Improved Modules</a><ul>
<li><a class="reference internal" href="#abc">abc</a></li>
<li><a class="reference internal" href="#array">array</a></li>
<li><a class="reference internal" href="#base64">base64</a></li>
<li><a class="reference internal" href="#binascii">binascii</a></li>
<li><a class="reference internal" href="#bz2">bz2</a></li>
<li><a class="reference internal" href="#codecs">codecs</a></li>
<li><a class="reference internal" href="#collections">collections</a></li>
<li><a class="reference internal" href="#contextlib">contextlib</a></li>
<li><a class="reference internal" href="#crypt">crypt</a></li>
<li><a class="reference internal" href="#curses">curses</a></li>
<li><a class="reference internal" href="#datetime">datetime</a></li>
<li><a class="reference internal" href="#decimal">decimal</a><ul>
<li><a class="reference internal" href="#id1">Features</a></li>
<li><a class="reference internal" href="#id2">API changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#email">email</a><ul>
<li><a class="reference internal" href="#policy-framework">Policy Framework</a></li>
<li><a class="reference internal" href="#provisional-policy-with-new-header-api">Provisional Policy with New Header API</a></li>
<li><a class="reference internal" href="#other-api-changes">Other API Changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#ftplib">ftplib</a></li>
<li><a class="reference internal" href="#functools">functools</a></li>
<li><a class="reference internal" href="#gc">gc</a></li>
<li><a class="reference internal" href="#hmac">hmac</a></li>
<li><a class="reference internal" href="#http">http</a></li>
<li><a class="reference internal" href="#html">html</a></li>
<li><a class="reference internal" href="#imaplib">imaplib</a></li>
<li><a class="reference internal" href="#inspect">inspect</a></li>
<li><a class="reference internal" href="#io">io</a></li>
<li><a class="reference internal" href="#itertools">itertools</a></li>
<li><a class="reference internal" href="#logging">logging</a></li>
<li><a class="reference internal" href="#math">math</a></li>
<li><a class="reference internal" href="#mmap">mmap</a></li>
<li><a class="reference internal" href="#multiprocessing">multiprocessing</a></li>
<li><a class="reference internal" href="#nntplib">nntplib</a></li>
<li><a class="reference internal" href="#os">os</a></li>
<li><a class="reference internal" href="#pdb">pdb</a></li>
<li><a class="reference internal" href="#pickle">pickle</a></li>
<li><a class="reference internal" href="#pydoc">pydoc</a></li>
<li><a class="reference internal" href="#re">re</a></li>
<li><a class="reference internal" href="#sched">sched</a></li>
<li><a class="reference internal" href="#select">select</a></li>
<li><a class="reference internal" href="#shlex">shlex</a></li>
<li><a class="reference internal" href="#shutil">shutil</a></li>
<li><a class="reference internal" href="#signal">signal</a></li>
<li><a class="reference internal" href="#smtpd">smtpd</a></li>
<li><a class="reference internal" href="#smtplib">smtplib</a></li>
<li><a class="reference internal" href="#socket">socket</a></li>
<li><a class="reference internal" href="#socketserver">socketserver</a></li>
<li><a class="reference internal" href="#sqlite3">sqlite3</a></li>
<li><a class="reference internal" href="#ssl">ssl</a></li>
<li><a class="reference internal" href="#stat">stat</a></li>
<li><a class="reference internal" href="#struct">struct</a></li>
<li><a class="reference internal" href="#subprocess">subprocess</a></li>
<li><a class="reference internal" href="#sys">sys</a></li>
<li><a class="reference internal" href="#tarfile">tarfile</a></li>
<li><a class="reference internal" href="#tempfile">tempfile</a></li>
<li><a class="reference internal" href="#textwrap">textwrap</a></li>
<li><a class="reference internal" href="#threading">threading</a></li>
<li><a class="reference internal" href="#time">time</a></li>
<li><a class="reference internal" href="#types">types</a></li>
<li><a class="reference internal" href="#unittest">unittest</a></li>
<li><a class="reference internal" href="#urllib">urllib</a></li>
<li><a class="reference internal" href="#webbrowser">webbrowser</a></li>
<li><a class="reference internal" href="#xml-etree-elementtree">xml.etree.ElementTree</a></li>
<li><a class="reference internal" href="#zlib">zlib</a></li>
</ul>
</li>
<li><a class="reference internal" href="#optimizations">Optimizations</a></li>
<li><a class="reference internal" href="#build-and-c-api-changes">Build and C API Changes</a></li>
<li><a class="reference internal" href="#deprecated">Deprecated</a><ul>
<li><a class="reference internal" href="#unsupported-operating-systems">Unsupported Operating Systems</a></li>
<li><a class="reference internal" href="#deprecated-python-modules-functions-and-methods">Deprecated Python modules, functions and methods</a></li>
<li><a class="reference internal" href="#deprecated-functions-and-types-of-the-c-api">Deprecated functions and types of the C API</a></li>
<li><a class="reference internal" href="#deprecated-features">Deprecated features</a></li>
</ul>
</li>
<li><a class="reference internal" href="#porting-to-python-3-3">Porting to Python 3.3</a><ul>
<li><a class="reference internal" href="#porting-python-code">Porting Python code</a></li>
<li><a class="reference internal" href="#porting-c-code">Porting C code</a></li>
<li><a class="reference internal" href="#building-c-extensions">Building C extensions</a></li>
<li><a class="reference internal" href="#command-line-switch-changes">Command Line Switch Changes</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Önceki konu</h4>
<p class="topless"><a href="3.4.html"
title="önceki bölüm">What’s New In Python 3.4</a></p>
</div>
<div>
<h4>Sonraki konu</h4>
<p class="topless"><a href="3.2.html"
title="sonraki bölüm">What’s New In Python 3.2</a></p>
</div>
<div role="note" aria-label="source link">
<h3>Bu Sayfa</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Hata Bildir</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.11/Doc/whatsnew/3.3.rst"
rel="nofollow">Kaynağı Göster
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Gezinti</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="Genel Endeks"
accesskey="I">dizin</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Modül Dizini"
>modülleri</a> |</li>
<li class="right" >
<a href="3.2.html" title="What’s New In Python 3.2"
accesskey="N">sonraki</a> |</li>
<li class="right" >
<a href="3.4.html" title="What’s New In Python 3.4"
accesskey="P">önceki</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> »</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.11.5 Documentation</a> »
</li>
<li class="nav-item nav-item-1"><a href="index.html" accesskey="U">What’s New in Python</a> »</li>
<li class="nav-item nav-item-this"><a href="">What’s New In Python 3.3</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Hızlı Arama" aria-label="Hızlı Arama" type="search" name="q" id="search-box" />
<input type="submit" value="Git" />
</form>
</div>
|
</li>
<li class="right">
<label class="theme-selector-label">
Theme
<select class="theme-selector" oninput="activateTheme(this.value)">
<option value="auto" selected>Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</label> |</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="what-s-new-in-python-3-3">
<h1>What’s New In Python 3.3<a class="headerlink" href="#what-s-new-in-python-3-3" title="Permalink to this heading">¶</a></h1>
<p>This article explains the new features in Python 3.3, compared to 3.2.
Python 3.3 was released on September 29, 2012. For full details,
see the <a class="reference external" href="https://docs.python.org/3.3/whatsnew/changelog.html">changelog</a>.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<p><span class="target" id="index-0"></span><a class="pep reference external" href="https://peps.python.org/pep-0398/"><strong>PEP 398</strong></a> - Python 3.3 Release Schedule</p>
</div>
<section id="summary-release-highlights">
<h2>Summary – Release highlights<a class="headerlink" href="#summary-release-highlights" title="Permalink to this heading">¶</a></h2>
<p>New syntax features:</p>
<ul class="simple">
<li><p>New <code class="docutils literal notranslate"><span class="pre">yield</span> <span class="pre">from</span></code> expression for <a class="reference internal" href="#pep-380"><span class="std std-ref">generator delegation</span></a>.</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">u'unicode'</span></code> syntax is accepted again for <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> objects.</p></li>
</ul>
<p>New library modules:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/faulthandler.html#module-faulthandler" title="faulthandler: Dump the Python traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">faulthandler</span></code></a> (helps debugging low-level crashes)</p></li>
<li><p><a class="reference internal" href="../library/ipaddress.html#module-ipaddress" title="ipaddress: IPv4/IPv6 manipulation library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">ipaddress</span></code></a> (high-level objects representing IP addresses and masks)</p></li>
<li><p><a class="reference internal" href="../library/lzma.html#module-lzma" title="lzma: A Python wrapper for the liblzma compression library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">lzma</span></code></a> (compress data using the XZ / LZMA algorithm)</p></li>
<li><p><a class="reference internal" href="../library/unittest.mock.html#module-unittest.mock" title="unittest.mock: Mock object library."><code class="xref py py-mod docutils literal notranslate"><span class="pre">unittest.mock</span></code></a> (replace parts of your system under test with mock objects)</p></li>
<li><p><a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> (Python <a class="reference internal" href="#pep-405"><span class="std std-ref">virtual environments</span></a>, as in the
popular <code class="docutils literal notranslate"><span class="pre">virtualenv</span></code> package)</p></li>
</ul>
<p>New built-in features:</p>
<ul class="simple">
<li><p>Reworked <a class="reference internal" href="#pep-3151"><span class="std std-ref">I/O exception hierarchy</span></a>.</p></li>
</ul>
<p>Implementation improvements:</p>
<ul class="simple">
<li><p>Rewritten <a class="reference internal" href="#importlib"><span class="std std-ref">import machinery</span></a> based on <a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a>.</p></li>
<li><p>More compact <a class="reference internal" href="#pep-393"><span class="std std-ref">unicode strings</span></a>.</p></li>
<li><p>More compact <a class="reference internal" href="#pep-412"><span class="std std-ref">attribute dictionaries</span></a>.</p></li>
</ul>
<p>Significantly Improved Library Modules:</p>
<ul class="simple">
<li><p>C Accelerator for the <a class="reference internal" href="#new-decimal"><span class="std std-ref">decimal</span></a> module.</p></li>
<li><p>Better unicode handling in the <a class="reference internal" href="#new-email"><span class="std std-ref">email</span></a> module
(<a class="reference internal" href="../glossary.html#term-provisional-package"><span class="xref std std-term">provisional</span></a>).</p></li>
</ul>
<p>Security improvements:</p>
<ul class="simple">
<li><p>Hash randomization is switched on by default.</p></li>
</ul>
<p>Please read on for a comprehensive list of user-facing changes.</p>
</section>
<section id="pep-405-virtual-environments">
<span id="pep-405"></span><h2>PEP 405: Virtual Environments<a class="headerlink" href="#pep-405-virtual-environments" title="Permalink to this heading">¶</a></h2>
<p>Virtual environments help create separate Python setups while sharing a
system-wide base install, for ease of maintenance. Virtual environments
have their own set of private site packages (i.e. locally installed
libraries), and are optionally segregated from the system-wide site
packages. Their concept and implementation are inspired by the popular
<code class="docutils literal notranslate"><span class="pre">virtualenv</span></code> third-party package, but benefit from tighter integration
with the interpreter core.</p>
<p>This PEP adds the <a class="reference internal" href="../library/venv.html#module-venv" title="venv: Creation of virtual environments."><code class="xref py py-mod docutils literal notranslate"><span class="pre">venv</span></code></a> module for programmatic access, and the
<code class="docutils literal notranslate"><span class="pre">pyvenv</span></code> script for command-line access and
administration. The Python interpreter checks for a <code class="docutils literal notranslate"><span class="pre">pyvenv.cfg</span></code>,
file whose existence signals the base of a virtual environment’s directory
tree.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0405/"><strong>PEP 405</strong></a> - Python Virtual Environments</dt><dd><p>PEP written by Carl Meyer; implementation by Carl Meyer and Vinay Sajip</p>
</dd>
</dl>
</div>
</section>
<section id="pep-420-implicit-namespace-packages">
<h2>PEP 420: Implicit Namespace Packages<a class="headerlink" href="#pep-420-implicit-namespace-packages" title="Permalink to this heading">¶</a></h2>
<p>Native support for package directories that don’t require <code class="docutils literal notranslate"><span class="pre">__init__.py</span></code>
marker files and can automatically span multiple path segments (inspired by
various third party approaches to namespace packages, as described in
<span class="target" id="index-2"></span><a class="pep reference external" href="https://peps.python.org/pep-0420/"><strong>PEP 420</strong></a>)</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-3"></span><a class="pep reference external" href="https://peps.python.org/pep-0420/"><strong>PEP 420</strong></a> - Implicit Namespace Packages</dt><dd><p>PEP written by Eric V. Smith; implementation by Eric V. Smith
and Barry Warsaw</p>
</dd>
</dl>
</div>
</section>
<section id="pep-3118-new-memoryview-implementation-and-buffer-protocol-documentation">
<span id="pep-3118-update"></span><h2>PEP 3118: New memoryview implementation and buffer protocol documentation<a class="headerlink" href="#pep-3118-new-memoryview-implementation-and-buffer-protocol-documentation" title="Permalink to this heading">¶</a></h2>
<p>The implementation of <span class="target" id="index-4"></span><a class="pep reference external" href="https://peps.python.org/pep-3118/"><strong>PEP 3118</strong></a> has been significantly improved.</p>
<p>The new memoryview implementation comprehensively fixes all ownership and
lifetime issues of dynamically allocated fields in the Py_buffer struct
that led to multiple crash reports. Additionally, several functions that
crashed or returned incorrect results for non-contiguous or multi-dimensional
input have been fixed.</p>
<p>The memoryview object now has a PEP-3118 compliant getbufferproc()
that checks the consumer’s request type. Many new features have been
added, most of them work in full generality for non-contiguous arrays
and arrays with suboffsets.</p>
<p>The documentation has been updated, clearly spelling out responsibilities
for both exporters and consumers. Buffer request flags are grouped into
basic and compound flags. The memory layout of non-contiguous and
multi-dimensional NumPy-style arrays is explained.</p>
<section id="features">
<h3>Features<a class="headerlink" href="#features" title="Permalink to this heading">¶</a></h3>
<ul class="simple">
<li><p>All native single character format specifiers in struct module syntax
(optionally prefixed with ‘@’) are now supported.</p></li>
<li><p>With some restrictions, the cast() method allows changing of format and
shape of C-contiguous arrays.</p></li>
<li><p>Multi-dimensional list representations are supported for any array type.</p></li>
<li><p>Multi-dimensional comparisons are supported for any array type.</p></li>
<li><p>One-dimensional memoryviews of hashable (read-only) types with formats B,
b or c are now hashable. (Contributed by Antoine Pitrou in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=13411">bpo-13411</a>.)</p></li>
<li><p>Arbitrary slicing of any 1-D arrays type is supported. For example, it
is now possible to reverse a memoryview in O(1) by using a negative step.</p></li>
</ul>
</section>
<section id="api-changes">
<h3>API changes<a class="headerlink" href="#api-changes" title="Permalink to this heading">¶</a></h3>
<ul class="simple">
<li><p>The maximum number of dimensions is officially limited to 64.</p></li>
<li><p>The representation of empty shape, strides and suboffsets is now
an empty tuple instead of <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p></li>
<li><p>Accessing a memoryview element with format ‘B’ (unsigned bytes)
now returns an integer (in accordance with the struct module syntax).
For returning a bytes object the view must be cast to ‘c’ first.</p></li>
<li><p>memoryview comparisons now use the logical structure of the operands
and compare all array elements by value. All format strings in struct
module syntax are supported. Views with unrecognised format strings
are still permitted, but will always compare as unequal, regardless
of view contents.</p></li>
<li><p>For further changes see <a class="reference internal" href="#build-and-c-api-changes">Build and C API Changes</a> and <a class="reference internal" href="#porting-c-code">Porting C code</a>.</p></li>
</ul>
<p>(Contributed by Stefan Krah in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=10181">bpo-10181</a>.)</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<p><span class="target" id="index-5"></span><a class="pep reference external" href="https://peps.python.org/pep-3118/"><strong>PEP 3118</strong></a> - Revising the Buffer Protocol</p>
</div>
</section>
</section>
<section id="pep-393-flexible-string-representation">
<span id="pep-393"></span><h2>PEP 393: Flexible String Representation<a class="headerlink" href="#pep-393-flexible-string-representation" title="Permalink to this heading">¶</a></h2>
<p>The Unicode string type is changed to support multiple internal
representations, depending on the character with the largest Unicode ordinal
(1, 2, or 4 bytes) in the represented string. This allows a space-efficient
representation in common cases, but gives access to full UCS-4 on all
systems. For compatibility with existing APIs, several representations may
exist in parallel; over time, this compatibility should be phased out.</p>
<p>On the Python side, there should be no downside to this change.</p>
<p>On the C API side, <span class="target" id="index-6"></span><a class="pep reference external" href="https://peps.python.org/pep-0393/"><strong>PEP 393</strong></a> is fully backward compatible. The legacy API
should remain available at least five years. Applications using the legacy
API will not fully benefit of the memory reduction, or - worse - may use
a bit more memory, because Python may have to maintain two versions of each
string (in the legacy format and in the new efficient storage).</p>
<section id="functionality">
<h3>Functionality<a class="headerlink" href="#functionality" title="Permalink to this heading">¶</a></h3>
<p>Changes introduced by <span class="target" id="index-7"></span><a class="pep reference external" href="https://peps.python.org/pep-0393/"><strong>PEP 393</strong></a> are the following:</p>
<ul class="simple">
<li><p>Python now always supports the full range of Unicode code points, including
non-BMP ones (i.e. from <code class="docutils literal notranslate"><span class="pre">U+0000</span></code> to <code class="docutils literal notranslate"><span class="pre">U+10FFFF</span></code>). The distinction between
narrow and wide builds no longer exists and Python now behaves like a wide
build, even under Windows.</p></li>
<li><p>With the death of narrow builds, the problems specific to narrow builds have
also been fixed, for example:</p>
<ul>
<li><p><a class="reference internal" href="../library/functions.html#len" title="len"><code class="xref py py-func docutils literal notranslate"><span class="pre">len()</span></code></a> now always returns 1 for non-BMP characters,
so <code class="docutils literal notranslate"><span class="pre">len('\U0010FFFF')</span> <span class="pre">==</span> <span class="pre">1</span></code>;</p></li>
<li><p>surrogate pairs are not recombined in string literals,
so <code class="docutils literal notranslate"><span class="pre">'\uDBFF\uDFFF'</span> <span class="pre">!=</span> <span class="pre">'\U0010FFFF'</span></code>;</p></li>
<li><p>indexing or slicing non-BMP characters returns the expected value,
so <code class="docutils literal notranslate"><span class="pre">'\U0010FFFF'[0]</span></code> now returns <code class="docutils literal notranslate"><span class="pre">'\U0010FFFF'</span></code> and not <code class="docutils literal notranslate"><span class="pre">'\uDBFF'</span></code>;</p></li>
<li><p>all other functions in the standard library now correctly handle
non-BMP code points.</p></li>
</ul>
</li>
<li><p>The value of <a class="reference internal" href="../library/sys.html#sys.maxunicode" title="sys.maxunicode"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.maxunicode</span></code></a> is now always <code class="docutils literal notranslate"><span class="pre">1114111</span></code> (<code class="docutils literal notranslate"><span class="pre">0x10FFFF</span></code>
in hexadecimal). The <code class="xref c c-func docutils literal notranslate"><span class="pre">PyUnicode_GetMax()</span></code> function still returns
either <code class="docutils literal notranslate"><span class="pre">0xFFFF</span></code> or <code class="docutils literal notranslate"><span class="pre">0x10FFFF</span></code> for backward compatibility, and it should
not be used with the new Unicode API (see <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=13054">bpo-13054</a>).</p></li>
<li><p>The <code class="file docutils literal notranslate"><span class="pre">./configure</span></code> flag <code class="docutils literal notranslate"><span class="pre">--with-wide-unicode</span></code> has been removed.</p></li>
</ul>
</section>
<section id="performance-and-resource-usage">
<h3>Performance and resource usage<a class="headerlink" href="#performance-and-resource-usage" title="Permalink to this heading">¶</a></h3>
<p>The storage of Unicode strings now depends on the highest code point in the string:</p>
<ul class="simple">
<li><p>pure ASCII and Latin1 strings (<code class="docutils literal notranslate"><span class="pre">U+0000-U+00FF</span></code>) use 1 byte per code point;</p></li>
<li><p>BMP strings (<code class="docutils literal notranslate"><span class="pre">U+0000-U+FFFF</span></code>) use 2 bytes per code point;</p></li>
<li><p>non-BMP strings (<code class="docutils literal notranslate"><span class="pre">U+10000-U+10FFFF</span></code>) use 4 bytes per code point.</p></li>
</ul>
<p>The net effect is that for most applications, memory usage of string
storage should decrease significantly - especially compared to former
wide unicode builds - as, in many cases, strings will be pure ASCII
even in international contexts (because many strings store non-human
language data, such as XML fragments, HTTP headers, JSON-encoded data,
etc.). We also hope that it will, for the same reasons, increase CPU
cache efficiency on non-trivial applications. The memory usage of
Python 3.3 is two to three times smaller than Python 3.2, and a little
bit better than Python 2.7, on a Django benchmark (see the PEP for
details).</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-8"></span><a class="pep reference external" href="https://peps.python.org/pep-0393/"><strong>PEP 393</strong></a> - Flexible String Representation</dt><dd><p>PEP written by Martin von Löwis; implementation by Torsten Becker
and Martin von Löwis.</p>
</dd>
</dl>
</div>
</section>
</section>
<section id="pep-397-python-launcher-for-windows">
<span id="pep-397"></span><h2>PEP 397: Python Launcher for Windows<a class="headerlink" href="#pep-397-python-launcher-for-windows" title="Permalink to this heading">¶</a></h2>
<p>The Python 3.3 Windows installer now includes a <code class="docutils literal notranslate"><span class="pre">py</span></code> launcher application
that can be used to launch Python applications in a version independent
fashion.</p>
<p>This launcher is invoked implicitly when double-clicking <code class="docutils literal notranslate"><span class="pre">*.py</span></code> files.
If only a single Python version is installed on the system, that version
will be used to run the file. If multiple versions are installed, the most
recent version is used by default, but this can be overridden by including
a Unix-style “shebang line” in the Python script.</p>
<p>The launcher can also be used explicitly from the command line as the <code class="docutils literal notranslate"><span class="pre">py</span></code>
application. Running <code class="docutils literal notranslate"><span class="pre">py</span></code> follows the same version selection rules as
implicitly launching scripts, but a more specific version can be selected
by passing appropriate arguments (such as <code class="docutils literal notranslate"><span class="pre">-3</span></code> to request Python 3 when
Python 2 is also installed, or <code class="docutils literal notranslate"><span class="pre">-2.6</span></code> to specifically request an earlier
Python version when a more recent version is installed).</p>
<p>In addition to the launcher, the Windows installer now includes an
option to add the newly installed Python to the system PATH. (Contributed
by Brian Curtin in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=3561">bpo-3561</a>.)</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-9"></span><a class="pep reference external" href="https://peps.python.org/pep-0397/"><strong>PEP 397</strong></a> - Python Launcher for Windows</dt><dd><p>PEP written by Mark Hammond and Martin v. Löwis; implementation by
Vinay Sajip.</p>
</dd>
</dl>
<p>Launcher documentation: <a class="reference internal" href="../using/windows.html#launcher"><span class="std std-ref">Python Launcher for Windows</span></a></p>
<p>Installer PATH modification: <a class="reference internal" href="../using/windows.html#windows-path-mod"><span class="std std-ref">Finding the Python executable</span></a></p>
</div>
</section>
<section id="pep-3151-reworking-the-os-and-io-exception-hierarchy">
<span id="pep-3151"></span><h2>PEP 3151: Reworking the OS and IO exception hierarchy<a class="headerlink" href="#pep-3151-reworking-the-os-and-io-exception-hierarchy" title="Permalink to this heading">¶</a></h2>
<p>The hierarchy of exceptions raised by operating system errors is now both
simplified and finer-grained.</p>
<p>You don’t have to worry anymore about choosing the appropriate exception
type between <a class="reference internal" href="../library/exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>, <a class="reference internal" href="../library/exceptions.html#IOError" title="IOError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IOError</span></code></a>, <a class="reference internal" href="../library/exceptions.html#EnvironmentError" title="EnvironmentError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">EnvironmentError</span></code></a>,
<a class="reference internal" href="../library/exceptions.html#WindowsError" title="WindowsError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">WindowsError</span></code></a>, <code class="xref py py-exc docutils literal notranslate"><span class="pre">mmap.error</span></code>, <a class="reference internal" href="../library/socket.html#socket.error" title="socket.error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">socket.error</span></code></a> or
<a class="reference internal" href="../library/select.html#select.error" title="select.error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">select.error</span></code></a>. All these exception types are now only one:
<a class="reference internal" href="../library/exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>. The other names are kept as aliases for compatibility
reasons.</p>
<p>Also, it is now easier to catch a specific error condition. Instead of
inspecting the <code class="docutils literal notranslate"><span class="pre">errno</span></code> attribute (or <code class="docutils literal notranslate"><span class="pre">args[0]</span></code>) for a particular
constant from the <a class="reference internal" href="../library/errno.html#module-errno" title="errno: Standard errno system symbols."><code class="xref py py-mod docutils literal notranslate"><span class="pre">errno</span></code></a> module, you can catch the adequate
<a class="reference internal" href="../library/exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> subclass. The available subclasses are the following:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/exceptions.html#BlockingIOError" title="BlockingIOError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BlockingIOError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#ChildProcessError" title="ChildProcessError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ChildProcessError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#ConnectionError" title="ConnectionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#FileExistsError" title="FileExistsError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FileExistsError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#FileNotFoundError" title="FileNotFoundError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">FileNotFoundError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#InterruptedError" title="InterruptedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptedError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#IsADirectoryError" title="IsADirectoryError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IsADirectoryError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#NotADirectoryError" title="NotADirectoryError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">NotADirectoryError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#PermissionError" title="PermissionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">PermissionError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#ProcessLookupError" title="ProcessLookupError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ProcessLookupError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#TimeoutError" title="TimeoutError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TimeoutError</span></code></a></p></li>
</ul>
<p>And the <a class="reference internal" href="../library/exceptions.html#ConnectionError" title="ConnectionError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionError</span></code></a> itself has finer-grained subclasses:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/exceptions.html#BrokenPipeError" title="BrokenPipeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BrokenPipeError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#ConnectionAbortedError" title="ConnectionAbortedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionAbortedError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#ConnectionRefusedError" title="ConnectionRefusedError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionRefusedError</span></code></a></p></li>
<li><p><a class="reference internal" href="../library/exceptions.html#ConnectionResetError" title="ConnectionResetError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ConnectionResetError</span></code></a></p></li>
</ul>
<p>Thanks to the new exceptions, common usages of the <a class="reference internal" href="../library/errno.html#module-errno" title="errno: Standard errno system symbols."><code class="xref py py-mod docutils literal notranslate"><span class="pre">errno</span></code></a> can now be
avoided. For example, the following code written for Python 3.2:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">errno</span> <span class="kn">import</span> <span class="n">ENOENT</span><span class="p">,</span> <span class="n">EACCES</span><span class="p">,</span> <span class="n">EPERM</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"document.txt"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">content</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">IOError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
<span class="k">if</span> <span class="n">err</span><span class="o">.</span><span class="n">errno</span> <span class="o">==</span> <span class="n">ENOENT</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"document.txt file is missing"</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">err</span><span class="o">.</span><span class="n">errno</span> <span class="ow">in</span> <span class="p">(</span><span class="n">EACCES</span><span class="p">,</span> <span class="n">EPERM</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"You are not allowed to read document.txt"</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span>
</pre></div>
</div>
<p>can now be written without the <a class="reference internal" href="../library/errno.html#module-errno" title="errno: Standard errno system symbols."><code class="xref py py-mod docutils literal notranslate"><span class="pre">errno</span></code></a> import and without manual
inspection of exception attributes:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">try</span><span class="p">:</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"document.txt"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">content</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">FileNotFoundError</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"document.txt file is missing"</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">PermissionError</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"You are not allowed to read document.txt"</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-10"></span><a class="pep reference external" href="https://peps.python.org/pep-3151/"><strong>PEP 3151</strong></a> - Reworking the OS and IO Exception Hierarchy</dt><dd><p>PEP written and implemented by Antoine Pitrou</p>
</dd>
</dl>
</div>
</section>
<section id="pep-380-syntax-for-delegating-to-a-subgenerator">
<span id="pep-380"></span><span id="index-11"></span><h2>PEP 380: Syntax for Delegating to a Subgenerator<a class="headerlink" href="#pep-380-syntax-for-delegating-to-a-subgenerator" title="Permalink to this heading">¶</a></h2>
<p>PEP 380 adds the <code class="docutils literal notranslate"><span class="pre">yield</span> <span class="pre">from</span></code> expression, allowing a <a class="reference internal" href="../glossary.html#term-generator"><span class="xref std std-term">generator</span></a> to
delegate
part of its operations to another generator. This allows a section of code
containing <a class="reference internal" href="../reference/simple_stmts.html#yield"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">yield</span></code></a> to be factored out and placed in another generator.
Additionally, the subgenerator is allowed to return with a value, and the
value is made available to the delegating generator.</p>
<p>While designed primarily for use in delegating to a subgenerator, the <code class="docutils literal notranslate"><span class="pre">yield</span>
<span class="pre">from</span></code> expression actually allows delegation to arbitrary subiterators.</p>
<p>For simple iterators, <code class="docutils literal notranslate"><span class="pre">yield</span> <span class="pre">from</span> <span class="pre">iterable</span></code> is essentially just a shortened
form of <code class="docutils literal notranslate"><span class="pre">for</span> <span class="pre">item</span> <span class="pre">in</span> <span class="pre">iterable:</span> <span class="pre">yield</span> <span class="pre">item</span></code>:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">g</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">yield from</span> <span class="nb">range</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
<span class="gp">... </span> <span class="k">yield from</span> <span class="nb">range</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="nb">list</span><span class="p">(</span><span class="n">g</span><span class="p">(</span><span class="mi">5</span><span class="p">))</span>
<span class="go">[5, 4, 3, 2, 1, 0, 1, 2, 3, 4]</span>
</pre></div>
</div>
<p>However, unlike an ordinary loop, <code class="docutils literal notranslate"><span class="pre">yield</span> <span class="pre">from</span></code> allows subgenerators to
receive sent and thrown values directly from the calling scope, and
return a final value to the outer generator:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">accumulate</span><span class="p">():</span>
<span class="gp">... </span> <span class="n">tally</span> <span class="o">=</span> <span class="mi">0</span>
<span class="gp">... </span> <span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
<span class="gp">... </span> <span class="nb">next</span> <span class="o">=</span> <span class="k">yield</span>
<span class="gp">... </span> <span class="k">if</span> <span class="nb">next</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">return</span> <span class="n">tally</span>
<span class="gp">... </span> <span class="n">tally</span> <span class="o">+=</span> <span class="nb">next</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="k">def</span> <span class="nf">gather_tallies</span><span class="p">(</span><span class="n">tallies</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">tally</span> <span class="o">=</span> <span class="k">yield from</span> <span class="n">accumulate</span><span class="p">()</span>
<span class="gp">... </span> <span class="n">tallies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tally</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">tallies</span> <span class="o">=</span> <span class="p">[]</span>
<span class="gp">>>> </span><span class="n">acc</span> <span class="o">=</span> <span class="n">gather_tallies</span><span class="p">(</span><span class="n">tallies</span><span class="p">)</span>
<span class="gp">>>> </span><span class="nb">next</span><span class="p">(</span><span class="n">acc</span><span class="p">)</span> <span class="c1"># Ensure the accumulator is ready to accept values</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">acc</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">acc</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> <span class="c1"># Finish the first tally</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
<span class="gp">... </span> <span class="n">acc</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">acc</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span> <span class="c1"># Finish the second tally</span>
<span class="gp">>>> </span><span class="n">tallies</span>
<span class="go">[6, 10]</span>
</pre></div>
</div>
<p>The main principle driving this change is to allow even generators that are
designed to be used with the <code class="docutils literal notranslate"><span class="pre">send</span></code> and <code class="docutils literal notranslate"><span class="pre">throw</span></code> methods to be split into
multiple subgenerators as easily as a single large function can be split into
multiple subfunctions.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-12"></span><a class="pep reference external" href="https://peps.python.org/pep-0380/"><strong>PEP 380</strong></a> - Syntax for Delegating to a Subgenerator</dt><dd><p>PEP written by Greg Ewing; implementation by Greg Ewing, integrated into
3.3 by Renaud Blanch, Ryan Kelly and Nick Coghlan; documentation by
Zbigniew Jędrzejewski-Szmek and Nick Coghlan</p>
</dd>
</dl>
</div>
</section>
<section id="pep-409-suppressing-exception-context">
<h2>PEP 409: Suppressing exception context<a class="headerlink" href="#pep-409-suppressing-exception-context" title="Permalink to this heading">¶</a></h2>
<p>PEP 409 introduces new syntax that allows the display of the chained
exception context to be disabled. This allows cleaner error messages in
applications that convert between exception types:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">class</span> <span class="nc">D</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">extra</span><span class="p">):</span>
<span class="gp">... </span> <span class="bp">self</span><span class="o">.</span><span class="n">_extra_attributes</span> <span class="o">=</span> <span class="n">extra</span>
<span class="gp">... </span> <span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attr</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">try</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extra_attributes</span><span class="p">[</span><span class="n">attr</span><span class="p">]</span>
<span class="gp">... </span> <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span><span class="n">attr</span><span class="p">)</span> <span class="kn">from</span> <span class="kc">None</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">D</span><span class="p">({})</span><span class="o">.</span><span class="n">x</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
File <span class="nb">"<stdin>"</span>, line <span class="m">8</span>, in <span class="n">__getattr__</span>
<span class="gr">AttributeError</span>: <span class="n">x</span>
</pre></div>
</div>
<p>Without the <code class="docutils literal notranslate"><span class="pre">from</span> <span class="pre">None</span></code> suffix to suppress the cause, the original
exception would be displayed by default:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">class</span> <span class="nc">C</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">extra</span><span class="p">):</span>
<span class="gp">... </span> <span class="bp">self</span><span class="o">.</span><span class="n">_extra_attributes</span> <span class="o">=</span> <span class="n">extra</span>
<span class="gp">... </span> <span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">attr</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">try</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_extra_attributes</span><span class="p">[</span><span class="n">attr</span><span class="p">]</span>
<span class="gp">... </span> <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span><span class="n">attr</span><span class="p">)</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">C</span><span class="p">({})</span><span class="o">.</span><span class="n">x</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">6</span>, in <span class="n">__getattr__</span>
<span class="gr">KeyError</span>: <span class="n">'x'</span>
<span class="gt">During handling of the above exception, another exception occurred:</span>
<span class="gt">Traceback (most recent call last):</span>
File <span class="nb">"<stdin>"</span>, line <span class="m">1</span>, in <span class="n"><module></span>
File <span class="nb">"<stdin>"</span>, line <span class="m">8</span>, in <span class="n">__getattr__</span>
<span class="gr">AttributeError</span>: <span class="n">x</span>
</pre></div>
</div>
<p>No debugging capability is lost, as the original exception context remains
available if needed (for example, if an intervening library has incorrectly
suppressed valuable underlying details):</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">try</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">D</span><span class="p">({})</span><span class="o">.</span><span class="n">x</span>
<span class="gp">... </span><span class="k">except</span> <span class="ne">AttributeError</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
<span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="nb">repr</span><span class="p">(</span><span class="n">exc</span><span class="o">.</span><span class="n">__context__</span><span class="p">))</span>
<span class="gp">...</span>
<span class="go">KeyError('x',)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-13"></span><a class="pep reference external" href="https://peps.python.org/pep-0409/"><strong>PEP 409</strong></a> - Suppressing exception context</dt><dd><p>PEP written by Ethan Furman; implemented by Ethan Furman and Nick
Coghlan.</p>
</dd>
</dl>
</div>
</section>
<section id="pep-414-explicit-unicode-literals">
<h2>PEP 414: Explicit Unicode literals<a class="headerlink" href="#pep-414-explicit-unicode-literals" title="Permalink to this heading">¶</a></h2>
<p>To ease the transition from Python 2 for Unicode aware Python applications
that make heavy use of Unicode literals, Python 3.3 once again supports the
“<code class="docutils literal notranslate"><span class="pre">u</span></code>” prefix for string literals. This prefix has no semantic significance
in Python 3, it is provided solely to reduce the number of purely mechanical
changes in migrating to Python 3, making it easier for developers to focus on
the more significant semantic changes (such as the stricter default
separation of binary and text data).</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-14"></span><a class="pep reference external" href="https://peps.python.org/pep-0414/"><strong>PEP 414</strong></a> - Explicit Unicode literals</dt><dd><p>PEP written by Armin Ronacher.</p>
</dd>
</dl>
</div>
</section>
<section id="pep-3155-qualified-name-for-classes-and-functions">
<h2>PEP 3155: Qualified name for classes and functions<a class="headerlink" href="#pep-3155-qualified-name-for-classes-and-functions" title="Permalink to this heading">¶</a></h2>
<p>Functions and class objects have a new <code class="docutils literal notranslate"><span class="pre">__qualname__</span></code> attribute representing
the “path” from the module top-level to their definition. For global functions
and classes, this is the same as <code class="docutils literal notranslate"><span class="pre">__name__</span></code>. For other functions and classes,
it provides better information about where they were actually defined, and
how they might be accessible from the global scope.</p>
<p>Example with (non-bound) methods:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">class</span> <span class="nc">C</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">def</span> <span class="nf">meth</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">pass</span>
<span class="gp">>>> </span><span class="n">C</span><span class="o">.</span><span class="n">meth</span><span class="o">.</span><span class="vm">__name__</span>
<span class="go">'meth'</span>
<span class="gp">>>> </span><span class="n">C</span><span class="o">.</span><span class="n">meth</span><span class="o">.</span><span class="vm">__qualname__</span>
<span class="go">'C.meth'</span>
</pre></div>
</div>
<p>Example with nested classes:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">class</span> <span class="nc">C</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">class</span> <span class="nc">D</span><span class="p">:</span>
<span class="gp">... </span> <span class="k">def</span> <span class="nf">meth</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">pass</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="o">.</span><span class="vm">__name__</span>
<span class="go">'D'</span>
<span class="gp">>>> </span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="o">.</span><span class="vm">__qualname__</span>
<span class="go">'C.D'</span>
<span class="gp">>>> </span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="o">.</span><span class="n">meth</span><span class="o">.</span><span class="vm">__name__</span>
<span class="go">'meth'</span>
<span class="gp">>>> </span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="o">.</span><span class="n">meth</span><span class="o">.</span><span class="vm">__qualname__</span>
<span class="go">'C.D.meth'</span>
</pre></div>
</div>
<p>Example with nested functions:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">outer</span><span class="p">():</span>
<span class="gp">... </span> <span class="k">def</span> <span class="nf">inner</span><span class="p">():</span>
<span class="gp">... </span> <span class="k">pass</span>
<span class="gp">... </span> <span class="k">return</span> <span class="n">inner</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">outer</span><span class="p">()</span><span class="o">.</span><span class="vm">__name__</span>
<span class="go">'inner'</span>
<span class="gp">>>> </span><span class="n">outer</span><span class="p">()</span><span class="o">.</span><span class="vm">__qualname__</span>
<span class="go">'outer.<locals>.inner'</span>
</pre></div>
</div>
<p>The string representation of those objects is also changed to include the
new, more precise information:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">str</span><span class="p">(</span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="p">)</span>
<span class="go">"<class '__main__.C.D'>"</span>
<span class="gp">>>> </span><span class="nb">str</span><span class="p">(</span><span class="n">C</span><span class="o">.</span><span class="n">D</span><span class="o">.</span><span class="n">meth</span><span class="p">)</span>
<span class="go">'<function C.D.meth at 0x7f46b9fe31e0>'</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-15"></span><a class="pep reference external" href="https://peps.python.org/pep-3155/"><strong>PEP 3155</strong></a> - Qualified name for classes and functions</dt><dd><p>PEP written and implemented by Antoine Pitrou.</p>
</dd>
</dl>
</div>
</section>
<section id="pep-412-key-sharing-dictionary">
<span id="pep-412"></span><h2>PEP 412: Key-Sharing Dictionary<a class="headerlink" href="#pep-412-key-sharing-dictionary" title="Permalink to this heading">¶</a></h2>
<p>Dictionaries used for the storage of objects’ attributes are now able to
share part of their internal storage between each other (namely, the part
which stores the keys and their respective hashes). This reduces the memory
consumption of programs creating many instances of non-builtin types.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-16"></span><a class="pep reference external" href="https://peps.python.org/pep-0412/"><strong>PEP 412</strong></a> - Key-Sharing Dictionary</dt><dd><p>PEP written and implemented by Mark Shannon.</p>
</dd>
</dl>
</div>
</section>
<section id="pep-362-function-signature-object">
<h2>PEP 362: Function Signature Object<a class="headerlink" href="#pep-362-function-signature-object" title="Permalink to this heading">¶</a></h2>
<p>A new function <a class="reference internal" href="../library/inspect.html#inspect.signature" title="inspect.signature"><code class="xref py py-func docutils literal notranslate"><span class="pre">inspect.signature()</span></code></a> makes introspection of python
callables easy and straightforward. A broad range of callables is supported:
python functions, decorated or not, classes, and <a class="reference internal" href="../library/functools.html#functools.partial" title="functools.partial"><code class="xref py py-func docutils literal notranslate"><span class="pre">functools.partial()</span></code></a>
objects. New classes <a class="reference internal" href="../library/inspect.html#inspect.Signature" title="inspect.Signature"><code class="xref py py-class docutils literal notranslate"><span class="pre">inspect.Signature</span></code></a>, <a class="reference internal" href="../library/inspect.html#inspect.Parameter" title="inspect.Parameter"><code class="xref py py-class docutils literal notranslate"><span class="pre">inspect.Parameter</span></code></a>
and <a class="reference internal" href="../library/inspect.html#inspect.BoundArguments" title="inspect.BoundArguments"><code class="xref py py-class docutils literal notranslate"><span class="pre">inspect.BoundArguments</span></code></a> hold information about the call signatures,
such as, annotations, default values, parameters kinds, and bound arguments,
which considerably simplifies writing decorators and any code that validates
or amends calling signatures or arguments.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-17"></span><a class="pep reference external" href="https://peps.python.org/pep-0362/"><strong>PEP 362</strong></a>: - Function Signature Object</dt><dd><p>PEP written by Brett Cannon, Yury Selivanov, Larry Hastings, Jiwon Seo;
implemented by Yury Selivanov.</p>
</dd>
</dl>
</div>
</section>
<section id="pep-421-adding-sys-implementation">
<h2>PEP 421: Adding sys.implementation<a class="headerlink" href="#pep-421-adding-sys-implementation" title="Permalink to this heading">¶</a></h2>
<p>A new attribute on the <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module exposes details specific to the
implementation of the currently running interpreter. The initial set of
attributes on <a class="reference internal" href="../library/sys.html#sys.implementation" title="sys.implementation"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.implementation</span></code></a> are <code class="docutils literal notranslate"><span class="pre">name</span></code>, <code class="docutils literal notranslate"><span class="pre">version</span></code>,
<code class="docutils literal notranslate"><span class="pre">hexversion</span></code>, and <code class="docutils literal notranslate"><span class="pre">cache_tag</span></code>.</p>
<p>The intention of <code class="docutils literal notranslate"><span class="pre">sys.implementation</span></code> is to consolidate into one namespace
the implementation-specific data used by the standard library. This allows
different Python implementations to share a single standard library code base
much more easily. In its initial state, <code class="docutils literal notranslate"><span class="pre">sys.implementation</span></code> holds only a
small portion of the implementation-specific data. Over time that ratio will
shift in order to make the standard library more portable.</p>
<p>One example of improved standard library portability is <code class="docutils literal notranslate"><span class="pre">cache_tag</span></code>. As of
Python 3.3, <code class="docutils literal notranslate"><span class="pre">sys.implementation.cache_tag</span></code> is used by <a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a> to
support <span class="target" id="index-18"></span><a class="pep reference external" href="https://peps.python.org/pep-3147/"><strong>PEP 3147</strong></a> compliance. Any Python implementation that uses
<code class="docutils literal notranslate"><span class="pre">importlib</span></code> for its built-in import system may use <code class="docutils literal notranslate"><span class="pre">cache_tag</span></code> to control
the caching behavior for modules.</p>
<section id="simplenamespace">
<h3>SimpleNamespace<a class="headerlink" href="#simplenamespace" title="Permalink to this heading">¶</a></h3>
<p>The implementation of <code class="docutils literal notranslate"><span class="pre">sys.implementation</span></code> also introduces a new type to
Python: <a class="reference internal" href="../library/types.html#types.SimpleNamespace" title="types.SimpleNamespace"><code class="xref py py-class docutils literal notranslate"><span class="pre">types.SimpleNamespace</span></code></a>. In contrast to a mapping-based
namespace, like <a class="reference internal" href="../library/stdtypes.html#dict" title="dict"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>, <code class="docutils literal notranslate"><span class="pre">SimpleNamespace</span></code> is attribute-based, like
<a class="reference internal" href="../library/functions.html#object" title="object"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a>. However, unlike <code class="docutils literal notranslate"><span class="pre">object</span></code>, <code class="docutils literal notranslate"><span class="pre">SimpleNamespace</span></code> instances
are writable. This means that you can add, remove, and modify the namespace
through normal attribute access.</p>
<div class="admonition seealso">
<p class="admonition-title">Ayrıca bakınız</p>
<dl class="simple">
<dt><span class="target" id="index-19"></span><a class="pep reference external" href="https://peps.python.org/pep-0421/"><strong>PEP 421</strong></a> - Adding sys.implementation</dt><dd><p>PEP written and implemented by Eric Snow.</p>
</dd>
</dl>
</div>
</section>
</section>
<section id="using-importlib-as-the-implementation-of-import">
<span id="importlib"></span><h2>Using importlib as the Implementation of Import<a class="headerlink" href="#using-importlib-as-the-implementation-of-import" title="Permalink to this heading">¶</a></h2>
<p><a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=2377">bpo-2377</a> - Replace __import__ w/ importlib.__import__
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=13959">bpo-13959</a> - Re-implement parts of <a class="reference internal" href="../library/imp.html#module-imp" title="imp: Access the implementation of the import statement. (kullanım dışı)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">imp</span></code></a> in pure Python
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=14605">bpo-14605</a> - Make import machinery explicit
<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=14646">bpo-14646</a> - Require loaders set __loader__ and __package__</p>
<p>The <a class="reference internal" href="../library/functions.html#import__" title="__import__"><code class="xref py py-func docutils literal notranslate"><span class="pre">__import__()</span></code></a> function is now powered by <a class="reference internal" href="../library/importlib.html#importlib.__import__" title="importlib.__import__"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.__import__()</span></code></a>.
This work leads to the completion of “phase 2” of <span class="target" id="index-20"></span><a class="pep reference external" href="https://peps.python.org/pep-0302/"><strong>PEP 302</strong></a>. There are
multiple benefits to this change. First, it has allowed for more of the
machinery powering import to be exposed instead of being implicit and hidden
within the C code. It also provides a single implementation for all Python VMs
supporting Python 3.3 to use, helping to end any VM-specific deviations in
import semantics. And finally it eases the maintenance of import, allowing for
future growth to occur.</p>
<p>For the common user, there should be no visible change in semantics. For
those whose code currently manipulates import or calls import
programmatically, the code changes that might possibly be required are covered
in the <a class="reference internal" href="#porting-python-code">Porting Python code</a> section of this document.</p>
<section id="new-apis">
<h3>New APIs<a class="headerlink" href="#new-apis" title="Permalink to this heading">¶</a></h3>
<p>One of the large benefits of this work is the exposure of what goes into
making the import statement work. That means the various importers that were
once implicit are now fully exposed as part of the <a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a> package.</p>
<p>The abstract base classes defined in <a class="reference internal" href="../library/importlib.html#module-importlib.abc" title="importlib.abc: Abstract base classes related to import"><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib.abc</span></code></a> have been expanded
to properly delineate between <a class="reference internal" href="../glossary.html#term-meta-path-finder"><span class="xref std std-term">meta path finders</span></a>
and <a class="reference internal" href="../glossary.html#term-path-entry-finder"><span class="xref std std-term">path entry finders</span></a> by introducing
<a class="reference internal" href="../library/importlib.html#importlib.abc.MetaPathFinder" title="importlib.abc.MetaPathFinder"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.MetaPathFinder</span></code></a> and
<a class="reference internal" href="../library/importlib.html#importlib.abc.PathEntryFinder" title="importlib.abc.PathEntryFinder"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.PathEntryFinder</span></code></a>, respectively. The old ABC of
<a class="reference internal" href="../library/importlib.html#importlib.abc.Finder" title="importlib.abc.Finder"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.Finder</span></code></a> is now only provided for backwards-compatibility
and does not enforce any method requirements.</p>
<p>In terms of finders, <a class="reference internal" href="../library/importlib.html#importlib.machinery.FileFinder" title="importlib.machinery.FileFinder"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.FileFinder</span></code></a> exposes the
mechanism used to search for source and bytecode files of a module. Previously
this class was an implicit member of <a class="reference internal" href="../library/sys.html#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a>.</p>
<p>For loaders, the new abstract base class <a class="reference internal" href="../library/importlib.html#importlib.abc.FileLoader" title="importlib.abc.FileLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.abc.FileLoader</span></code></a> helps
write a loader that uses the file system as the storage mechanism for a module’s
code. The loader for source files
(<a class="reference internal" href="../library/importlib.html#importlib.machinery.SourceFileLoader" title="importlib.machinery.SourceFileLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.SourceFileLoader</span></code></a>), sourceless bytecode files
(<a class="reference internal" href="../library/importlib.html#importlib.machinery.SourcelessFileLoader" title="importlib.machinery.SourcelessFileLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.SourcelessFileLoader</span></code></a>), and extension modules
(<a class="reference internal" href="../library/importlib.html#importlib.machinery.ExtensionFileLoader" title="importlib.machinery.ExtensionFileLoader"><code class="xref py py-class docutils literal notranslate"><span class="pre">importlib.machinery.ExtensionFileLoader</span></code></a>) are now available for
direct use.</p>
<p><a class="reference internal" href="../library/exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> now has <code class="docutils literal notranslate"><span class="pre">name</span></code> and <code class="docutils literal notranslate"><span class="pre">path</span></code> attributes which are set when
there is relevant data to provide. The message for failed imports will also
provide the full name of the module now instead of just the tail end of the
module’s name.</p>
<p>The <a class="reference internal" href="../library/importlib.html#importlib.invalidate_caches" title="importlib.invalidate_caches"><code class="xref py py-func docutils literal notranslate"><span class="pre">importlib.invalidate_caches()</span></code></a> function will now call the method with
the same name on all finders cached in <a class="reference internal" href="../library/sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_importer_cache</span></code></a> to help
clean up any stored state as necessary.</p>
</section>
<section id="visible-changes">
<h3>Visible Changes<a class="headerlink" href="#visible-changes" title="Permalink to this heading">¶</a></h3>
<p>For potential required changes to code, see the <a class="reference internal" href="#porting-python-code">Porting Python code</a>
section.</p>
<p>Beyond the expanse of what <a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a> now exposes, there are other
visible changes to import. The biggest is that <a class="reference internal" href="../library/sys.html#sys.meta_path" title="sys.meta_path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.meta_path</span></code></a> and
<a class="reference internal" href="../library/sys.html#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a> now store all of the meta path finders and path entry
hooks used by import. Previously the finders were implicit and hidden within
the C code of import instead of being directly exposed. This means that one can
now easily remove or change the order of the various finders to fit one’s needs.</p>
<p>Another change is that all modules have a <code class="docutils literal notranslate"><span class="pre">__loader__</span></code> attribute, storing the
loader used to create the module. <span class="target" id="index-21"></span><a class="pep reference external" href="https://peps.python.org/pep-0302/"><strong>PEP 302</strong></a> has been updated to make this
attribute mandatory for loaders to implement, so in the future once 3rd-party
loaders have been updated people will be able to rely on the existence of the
attribute. Until such time, though, import is setting the module post-load.</p>
<p>Loaders are also now expected to set the <code class="docutils literal notranslate"><span class="pre">__package__</span></code> attribute from
<span class="target" id="index-22"></span><a class="pep reference external" href="https://peps.python.org/pep-0366/"><strong>PEP 366</strong></a>. Once again, import itself is already setting this on all loaders
from <a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a> and import itself is setting the attribute post-load.</p>
<p><code class="docutils literal notranslate"><span class="pre">None</span></code> is now inserted into <a class="reference internal" href="../library/sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_importer_cache</span></code></a> when no finder
can be found on <a class="reference internal" href="../library/sys.html#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a>. Since <a class="reference internal" href="../library/imp.html#imp.NullImporter" title="imp.NullImporter"><code class="xref py py-class docutils literal notranslate"><span class="pre">imp.NullImporter</span></code></a> is not
directly exposed on <a class="reference internal" href="../library/sys.html#sys.path_hooks" title="sys.path_hooks"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path_hooks</span></code></a> it could no longer be relied upon to
always be available to use as a value representing no finder found.</p>
<p>All other changes relate to semantic changes which should be taken into
consideration when updating code for Python 3.3, and thus should be read about
in the <a class="reference internal" href="#porting-python-code">Porting Python code</a> section of this document.</p>
<p>(Implementation by Brett Cannon)</p>
</section>
</section>
<section id="other-language-changes">
<h2>Other Language Changes<a class="headerlink" href="#other-language-changes" title="Permalink to this heading">¶</a></h2>
<p>Some smaller changes made to the core Python language are:</p>
<ul>
<li><p>Added support for Unicode name aliases and named sequences.
Both <a class="reference internal" href="../library/unicodedata.html#unicodedata.lookup" title="unicodedata.lookup"><code class="xref py py-func docutils literal notranslate"><span class="pre">unicodedata.lookup()</span></code></a> and <code class="docutils literal notranslate"><span class="pre">'\N{...}'</span></code> now resolve name aliases,
and <a class="reference internal" href="../library/unicodedata.html#unicodedata.lookup" title="unicodedata.lookup"><code class="xref py py-func docutils literal notranslate"><span class="pre">unicodedata.lookup()</span></code></a> resolves named sequences too.</p>
<p>(Contributed by Ezio Melotti in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=12753">bpo-12753</a>.)</p>
</li>
<li><p>Unicode database updated to UCD version 6.1.0</p></li>
<li><p>Equality comparisons on <a class="reference internal" href="../library/stdtypes.html#range" title="range"><code class="xref py py-func docutils literal notranslate"><span class="pre">range()</span></code></a> objects now return a result reflecting
the equality of the underlying sequences generated by those range objects.
(<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=13201">bpo-13201</a>)</p></li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">count()</span></code>, <code class="docutils literal notranslate"><span class="pre">find()</span></code>, <code class="docutils literal notranslate"><span class="pre">rfind()</span></code>, <code class="docutils literal notranslate"><span class="pre">index()</span></code> and <code class="docutils literal notranslate"><span class="pre">rindex()</span></code>
methods of <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> objects now accept an
integer between 0 and 255 as their first argument.</p>
<p>(Contributed by Petri Lehtinen in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=12170">bpo-12170</a>.)</p>
</li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">rjust()</span></code>, <code class="docutils literal notranslate"><span class="pre">ljust()</span></code>, and <code class="docutils literal notranslate"><span class="pre">center()</span></code> methods of <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>
and <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> now accept a <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> for the <code class="docutils literal notranslate"><span class="pre">fill</span></code>
argument. (Contributed by Petri Lehtinen in <a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=12380">bpo-12380</a>.)</p></li>
<li><p>New methods have been added to <a class="reference internal" href="../library/stdtypes.html#list" title="list"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> and <a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a>:
<code class="docutils literal notranslate"><span class="pre">copy()</span></code> and <code class="docutils literal notranslate"><span class="pre">clear()</span></code> (<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=10516">bpo-10516</a>). Consequently,
<a class="reference internal" href="../library/collections.abc.html#collections.abc.MutableSequence" title="collections.abc.MutableSequence"><code class="xref py py-class docutils literal notranslate"><span class="pre">MutableSequence</span></code></a> now also defines a
<code class="xref py py-meth docutils literal notranslate"><span class="pre">clear()</span></code> method (<a class="reference external" href="https://bugs.python.org/issue?@action=redirect&bpo=11388">bpo-11388</a>).</p></li>