-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathprogramming.po
More file actions
2965 lines (2597 loc) · 127 KB
/
programming.po
File metadata and controls
2965 lines (2597 loc) · 127 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
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 1990-2016, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 2.7\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-30 10:44+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../Doc/faq/programming.rst:5
msgid "Programming FAQ"
msgstr "FAQ de programmation"
#: ../Doc/faq/programming.rst:12
msgid "General Questions"
msgstr "Questions générales"
#: ../Doc/faq/programming.rst:15
msgid ""
"Is there a source code level debugger with breakpoints, single-stepping, "
"etc.?"
msgstr ""
"Existe-t'il un débogueur de code source avec points d'arrêts, exécution pas-"
"à-pas, etc. ?"
#: ../Doc/faq/programming.rst:17 ../Doc/faq/programming.rst:60
msgid "Yes."
msgstr "Oui."
#: ../Doc/faq/programming.rst:19
msgid ""
"The pdb module is a simple but adequate console-mode debugger for Python. It "
"is part of the standard Python library, and is :mod:`documented in the "
"Library Reference Manual <pdb>`. You can also write your own debugger by "
"using the code for pdb as an example."
msgstr ""
"Le module pdb est un débogueur console simple, mais parfaitement adapté à "
"Python. Il fait partie de la bibliothèque standard de Python, sa "
"documentation se trouve dans le :mod:`manuel de référence <pdb>`. Vous "
"pouvez vous inspirer du code de pdb pour écrire votre propre débogueur."
#: ../Doc/faq/programming.rst:24
msgid ""
"The IDLE interactive development environment, which is part of the standard "
"Python distribution (normally available as Tools/scripts/idle), includes a "
"graphical debugger."
msgstr ""
"L'environnement de développement interactif IDLE, qui est fourni avec la "
"distribution standard de Python (normalement disponible dans Tools/scripts/"
"idle) contient un débogueur graphique."
#: ../Doc/faq/programming.rst:28
msgid ""
"PythonWin is a Python IDE that includes a GUI debugger based on pdb. The "
"Pythonwin debugger colors breakpoints and has quite a few cool features such "
"as debugging non-Pythonwin programs. Pythonwin is available as part of the "
"`Python for Windows Extensions <https://sourceforge.net/projects/pywin32/"
">`__ project and as a part of the ActivePython distribution (see https://www."
"activestate.com/activepython\\ )."
msgstr ""
"PythonWin est un environnement de développement intégré (EDI) Python qui "
"embarque un débogueur graphique basé sur pdb. Le débogueur PythonWin colore "
"les points d'arrêts et possède quelques fonctionnalités sympathiques, comme "
"la possibilité de déboguer des programmes développés sans PythonWin. "
"PythonWin est disponible dans le projet `Extensions Python pour Windows "
"<https://sourceforge.net/projects/pywin32/>`__ et fait partie de la "
"distribution ActivePython (voir https://www.activestate.com/activepython\\ )."
#: ../Doc/faq/programming.rst:35
msgid ""
"`Boa Constructor <http://boa-constructor.sourceforge.net/>`_ is an IDE and "
"GUI builder that uses wxWidgets. It offers visual frame creation and "
"manipulation, an object inspector, many views on the source like object "
"browsers, inheritance hierarchies, doc string generated html documentation, "
"an advanced debugger, integrated help, and Zope support."
msgstr ""
"`Boa Constructor <http://boa-constructor.sourceforge.net/>`_ est un EDI et "
"un constructeur d'interface homme-machine basé sur wxWidgets. Il propose la "
"création et la manipulation de fenêtres, un inspecteur d'objets, de "
"nombreuses façons de visualiser des sources comme un navigateur d'objets, "
"les hiérarchies d'héritage, la documentation html générée par les "
"docstrings, un débogueur avancé, une aide intégrée et la prise en charge de "
"Zope."
#: ../Doc/faq/programming.rst:41
msgid ""
"`Eric <http://eric-ide.python-projects.org/>`_ is an IDE built on PyQt and "
"the Scintilla editing component."
msgstr ""
"`Eric <http://eric-ide.python-projects.org/>`_ est un EDI basé sur PyQt et "
"l'outil d'édition Scintilla."
#: ../Doc/faq/programming.rst:44
msgid ""
"Pydb is a version of the standard Python debugger pdb, modified for use with "
"DDD (Data Display Debugger), a popular graphical debugger front end. Pydb "
"can be found at http://bashdb.sourceforge.net/pydb/ and DDD can be found at "
"https://www.gnu.org/software/ddd."
msgstr ""
"Pydb est une version du débogueur standard Python pdb, modifié pour être "
"utilisé avec DDD (Data Display Debugger), un célèbre débogueur graphique. "
"Pydb est disponible sur http://bashdb.sourceforge.net/pydb/ et DDD est "
"disponible sur https://www.gnu.org/software/ddd."
#: ../Doc/faq/programming.rst:49
msgid ""
"There are a number of commercial Python IDEs that include graphical "
"debuggers. They include:"
msgstr ""
"Il existe de nombreux EDI Python propriétaires qui embarquent un débogueur "
"graphique. Notamment :"
#: ../Doc/faq/programming.rst:52
msgid "Wing IDE (https://wingware.com/)"
msgstr "Wing IDE (https://wingware.com/)"
#: ../Doc/faq/programming.rst:53
msgid "Komodo IDE (https://komodoide.com/)"
msgstr "Komodo IDE (https://komodoide.com/)"
#: ../Doc/faq/programming.rst:54
msgid "PyCharm (https://www.jetbrains.com/pycharm/)"
msgstr "PyCharm (https://www.jetbrains.com/pycharm/)"
#: ../Doc/faq/programming.rst:58
msgid "Is there a tool to help find bugs or perform static analysis?"
msgstr ""
"Existe-t'il des outils pour aider à trouver des bogues ou faire de l'analyse "
"statique de code ?"
#: ../Doc/faq/programming.rst:62
msgid ""
"PyChecker is a static analysis tool that finds bugs in Python source code "
"and warns about code complexity and style. You can get PyChecker from "
"http://pychecker.sourceforge.net/."
msgstr ""
"PyChecker est un outil d'analyse statique qui trouve les bogues dans le code "
"source Python et émet des avertissements relatifs à la complexité et au "
"style du code. PyChecker est disponible sur http://pychecker.sourceforge."
"net/."
#: ../Doc/faq/programming.rst:66
msgid ""
"`Pylint <https://www.pylint.org/>`_ is another tool that checks if a module "
"satisfies a coding standard, and also makes it possible to write plug-ins to "
"add a custom feature. In addition to the bug checking that PyChecker "
"performs, Pylint offers some additional features such as checking line "
"length, whether variable names are well-formed according to your coding "
"standard, whether declared interfaces are fully implemented, and more. "
"https://docs.pylint.org/ provides a full list of Pylint's features."
msgstr ""
"Pylint <https://www.pylint.org/>`_ est un autre outil qui vérifie si un "
"module satisfait aux normes de développement, et qui permet en plus d'écrire "
"des greffons pour ajouter des fonctionnalités personnalisées. En plus de la "
"vérification des bogues effectuée par PyChecker, Pylint effectue quelques "
"vérifications supplémentaires comme la longueur des lignes, les conventions "
"de nommage des variables, que les interfaces déclarées sont implémentées en "
"totalité, et plus encore. https://docs.pylint.org/ fournit la liste complète "
"des fonctionnalités de Pylint."
#: ../Doc/faq/programming.rst:76
msgid "How can I create a stand-alone binary from a Python script?"
msgstr "Comment créer un binaire autonome à partir d'un script Python ?"
#: ../Doc/faq/programming.rst:78
msgid ""
"You don't need the ability to compile Python to C code if all you want is a "
"stand-alone program that users can download and run without having to "
"install the Python distribution first. There are a number of tools that "
"determine the set of modules required by a program and bind these modules "
"together with a Python binary to produce a single executable."
msgstr ""
"Pour créer un programme autonome, c'est-à-dire un programme que n'importe "
"qui peut télécharger et exécuter sans avoir à installer une distribution "
"Python au préalable, il n'est pas nécessaire de compiler du code Python en "
"code C. Il existe en effet plusieurs outils qui déterminent les modules "
"requis par un programme et lient ces modules avec un binaire Python pour "
"produire un seul exécutable."
#: ../Doc/faq/programming.rst:84
msgid ""
"One is to use the freeze tool, which is included in the Python source tree "
"as ``Tools/freeze``. It converts Python byte code to C arrays; a C compiler "
"you can embed all your modules into a new program, which is then linked with "
"the standard Python modules."
msgstr ""
"Un de ces outils est freeze, qui se trouve dans ``Tools/freeze`` de "
"l'arborescence des sources de Python. Il convertit le code intermédiaire "
"(*bytecode*) Python en tableaux C ; un compilateur C permet d'intégrer tous "
"vos modules dans un nouveau programme, qui est ensuite lié aux modules "
"standards Python."
#: ../Doc/faq/programming.rst:89
msgid ""
"It works by scanning your source recursively for import statements (in both "
"forms) and looking for the modules in the standard Python path as well as in "
"the source directory (for built-in modules). It then turns the bytecode for "
"modules written in Python into C code (array initializers that can be turned "
"into code objects using the marshal module) and creates a custom-made config "
"file that only contains those built-in modules which are actually used in "
"the program. It then compiles the generated C code and links it with the "
"rest of the Python interpreter to form a self-contained binary which acts "
"exactly like your script."
msgstr ""
"Il fonctionne en cherchant de manière récursive les instructions d'import "
"(sous les deux formes) dans le code source et en recherchant ces modules "
"dans le chemin Python standard ainsi que dans le répertoire source (pour les "
"modules natifs). Il transforme ensuite le code intermédiaire des modules "
"écrits en Python en code C (des tableaux pré-remplis qui peuvent être "
"transformés en objets code à l'aide du module *marshal*) et crée un fichier "
"de configuration personnalisé qui contient uniquement les modules natifs qui "
"sont réellement utilisés dans le programme. Il compile ensuite le code C "
"généré et le lie au reste de l'interpréteur Python pour former un binaire "
"autonome qui fait exactement la même chose que le script."
#: ../Doc/faq/programming.rst:98
msgid ""
"Obviously, freeze requires a C compiler. There are several other utilities "
"which don't. One is Thomas Heller's py2exe (Windows only) at"
msgstr ""
"Bien évidemment, freeze nécessite un compilateur C. Il existe d'autres "
"outils qui peuvent s'en passer. Un de ceux-ci est py2exe de Thomas Heller "
"(pour Windows uniquement) disponible sur"
#: ../Doc/faq/programming.rst:101
msgid "http://www.py2exe.org/"
msgstr "http://www.py2exe.org/"
#: ../Doc/faq/programming.rst:103
msgid ""
"Another tool is Anthony Tuininga's `cx_Freeze <http://cx-freeze.sourceforge."
"net/>`_."
msgstr ""
#: ../Doc/faq/programming.rst:107
msgid "Are there coding standards or a style guide for Python programs?"
msgstr ""
"Existe-t'il des normes de développement ou un guide de style pour écrire des "
"programmes Python ?"
#: ../Doc/faq/programming.rst:109
msgid ""
"Yes. The coding style required for standard library modules is documented "
"as :pep:`8`."
msgstr ""
"Oui. Le style de développement que les modules de la bibliothèque standard "
"doivent obligatoirement respecter est documenté dans la :pep:`8`."
#: ../Doc/faq/programming.rst:114
msgid "My program is too slow. How do I speed it up?"
msgstr "Mon programme est trop lent. Comment l'accélérer ?"
#: ../Doc/faq/programming.rst:116
msgid ""
"That's a tough one, in general. There are many tricks to speed up Python "
"code; consider rewriting parts in C as a last resort."
msgstr ""
#: ../Doc/faq/programming.rst:119
msgid ""
"In some cases it's possible to automatically translate Python to C or x86 "
"assembly language, meaning that you don't have to modify your code to gain "
"increased speed."
msgstr ""
#: ../Doc/faq/programming.rst:125
msgid ""
"`Pyrex <http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/>`_ can compile "
"a slightly modified version of Python code into a C extension, and can be "
"used on many different platforms."
msgstr ""
#: ../Doc/faq/programming.rst:129
msgid ""
"`Psyco <http://psyco.sourceforge.net>`_ is a just-in-time compiler that "
"translates Python code into x86 assembly language. If you can use it, Psyco "
"can provide dramatic speedups for critical functions."
msgstr ""
#: ../Doc/faq/programming.rst:133
msgid ""
"The rest of this answer will discuss various tricks for squeezing a bit more "
"speed out of Python code. *Never* apply any optimization tricks unless you "
"know you need them, after profiling has indicated that a particular function "
"is the heavily executed hot spot in the code. Optimizations almost always "
"make the code less clear, and you shouldn't pay the costs of reduced clarity "
"(increased development time, greater likelihood of bugs) unless the "
"resulting performance benefit is worth it."
msgstr ""
#: ../Doc/faq/programming.rst:141
msgid ""
"There is a page on the wiki devoted to `performance tips <https://wiki."
"python.org/moin/PythonSpeed/PerformanceTips>`_."
msgstr ""
#: ../Doc/faq/programming.rst:144
msgid ""
"Guido van Rossum has written up an anecdote related to optimization at "
"https://www.python.org/doc/essays/list2str."
msgstr ""
#: ../Doc/faq/programming.rst:147
msgid ""
"One thing to notice is that function and (especially) method calls are "
"rather expensive; if you have designed a purely OO interface with lots of "
"tiny functions that don't do much more than get or set an instance variable "
"or call another method, you might consider using a more direct way such as "
"directly accessing instance variables. Also see the standard module :mod:"
"`profile` which makes it possible to find out where your program is spending "
"most of its time (if you have some patience -- the profiling itself can slow "
"your program down by an order of magnitude)."
msgstr ""
#: ../Doc/faq/programming.rst:156
msgid ""
"Remember that many standard optimization heuristics you may know from other "
"programming experience may well apply to Python. For example it may be "
"faster to send output to output devices using larger writes rather than "
"smaller ones in order to reduce the overhead of kernel system calls. Thus "
"CGI scripts that write all output in \"one shot\" may be faster than those "
"that write lots of small pieces of output."
msgstr ""
#: ../Doc/faq/programming.rst:163
msgid ""
"Also, be sure to use Python's core features where appropriate. For example, "
"slicing allows programs to chop up lists and other sequence objects in a "
"single tick of the interpreter's mainloop using highly optimized C "
"implementations. Thus to get the same effect as::"
msgstr ""
#: ../Doc/faq/programming.rst:172
msgid "it is much shorter and far faster to use ::"
msgstr ""
#: ../Doc/faq/programming.rst:176
msgid ""
"Note that the functionally-oriented built-in functions such as :func:`map`, :"
"func:`zip`, and friends can be a convenient accelerator for loops that "
"perform a single task. For example to pair the elements of two lists "
"together::"
msgstr ""
#: ../Doc/faq/programming.rst:184
msgid "or to compute a number of sines::"
msgstr ""
#: ../Doc/faq/programming.rst:189
msgid "The operation completes very quickly in such cases."
msgstr ""
#: ../Doc/faq/programming.rst:191
msgid ""
"Other examples include the ``join()`` and ``split()`` :ref:`methods of "
"string objects <string-methods>`. For example if s1..s7 are large (10K+) "
"strings then ``\"\".join([s1,s2,s3,s4,s5,s6,s7])`` may be far faster than "
"the more obvious ``s1+s2+s3+s4+s5+s6+s7``, since the \"summation\" will "
"compute many subexpressions, whereas ``join()`` does all the copying in one "
"pass. For manipulating strings, use the ``replace()`` and the ``format()`` :"
"ref:`methods on string objects <string-methods>`. Use regular expressions "
"only when you're not dealing with constant string patterns. You may still "
"use :ref:`the old % operations <string-formatting>` ``string % tuple`` and "
"``string % dictionary``."
msgstr ""
#: ../Doc/faq/programming.rst:202
msgid ""
"Be sure to use the :meth:`list.sort` built-in method to do sorting, and see "
"the `sorting mini-HOWTO <https://wiki.python.org/moin/HowTo/Sorting>`_ for "
"examples of moderately advanced usage. :meth:`list.sort` beats other "
"techniques for sorting in all but the most extreme circumstances."
msgstr ""
#: ../Doc/faq/programming.rst:207
msgid ""
"Another common trick is to \"push loops into functions or methods.\" For "
"example suppose you have a program that runs slowly and you use the profiler "
"to determine that a Python function ``ff()`` is being called lots of times. "
"If you notice that ``ff()``::"
msgstr ""
#: ../Doc/faq/programming.rst:216
msgid "tends to be called in loops like::"
msgstr ""
#: ../Doc/faq/programming.rst:220
msgid "or::"
msgstr "ou : ::"
#: ../Doc/faq/programming.rst:226
msgid ""
"then you can often eliminate function call overhead by rewriting ``ff()`` "
"to::"
msgstr ""
#: ../Doc/faq/programming.rst:235
msgid "and rewrite the two examples to ``list = ffseq(oldlist)`` and to::"
msgstr ""
#: ../Doc/faq/programming.rst:240
msgid ""
"Single calls to ``ff(x)`` translate to ``ffseq([x])[0]`` with little "
"penalty. Of course this technique is not always appropriate and there are "
"other variants which you can figure out."
msgstr ""
#: ../Doc/faq/programming.rst:244
msgid ""
"You can gain some performance by explicitly storing the results of a "
"function or method lookup into a local variable. A loop like::"
msgstr ""
#: ../Doc/faq/programming.rst:250
msgid ""
"resolves ``dict.get`` every iteration. If the method isn't going to change, "
"a slightly faster implementation is::"
msgstr ""
#: ../Doc/faq/programming.rst:257
msgid ""
"Default arguments can be used to determine values once, at compile time "
"instead of at run time. This can only be done for functions or objects "
"which will not be changed during program execution, such as replacing ::"
msgstr ""
#: ../Doc/faq/programming.rst:264
msgid "with ::"
msgstr ""
#: ../Doc/faq/programming.rst:269
msgid ""
"Because this trick uses default arguments for terms which should not be "
"changed, it should only be used when you are not concerned with presenting a "
"possibly confusing API to your users."
msgstr ""
#: ../Doc/faq/programming.rst:275
msgid "Core Language"
msgstr "Fondamentaux"
#: ../Doc/faq/programming.rst:278
msgid "Why am I getting an UnboundLocalError when the variable has a value?"
msgstr ""
"Pourquoi une UnboundLocalError est levée alors qu'une variable a une valeur ?"
#: ../Doc/faq/programming.rst:280
msgid ""
"It can be a surprise to get the UnboundLocalError in previously working code "
"when it is modified by adding an assignment statement somewhere in the body "
"of a function."
msgstr ""
"Il est parfois surprenant d'obtenir une UnboundLocalError dans du code "
"jusqu'à présent correct, quand celui-ci est modifié en ajoutant une "
"instruction d'affectation quelque part dans le corps d'une fonction."
#: ../Doc/faq/programming.rst:284
msgid "This code:"
msgstr "Le code suivant :"
#: ../Doc/faq/programming.rst:292
msgid "works, but this code:"
msgstr "fonctionne, mais le suivant :"
#: ../Doc/faq/programming.rst:299
msgid "results in an UnboundLocalError:"
msgstr "lève une UnboundLocalError :"
#: ../Doc/faq/programming.rst:306
msgid ""
"This is because when you make an assignment to a variable in a scope, that "
"variable becomes local to that scope and shadows any similarly named "
"variable in the outer scope. Since the last statement in foo assigns a new "
"value to ``x``, the compiler recognizes it as a local variable. "
"Consequently when the earlier ``print x`` attempts to print the "
"uninitialized local variable and an error results."
msgstr ""
#: ../Doc/faq/programming.rst:313
msgid ""
"In the example above you can access the outer scope variable by declaring it "
"global:"
msgstr ""
"Dans l'exemple ci-dessus, la variable du contexte appelant reste accessible "
"en la déclarant globale :"
#: ../Doc/faq/programming.rst:324
msgid ""
"This explicit declaration is required in order to remind you that (unlike "
"the superficially analogous situation with class and instance variables) you "
"are actually modifying the value of the variable in the outer scope:"
msgstr ""
"Cette déclaration explicite est obligatoire pour se rappeler que "
"(contrairement au cas à peu près similaire avec des variables de classe et "
"d'instance), c'est la valeur de la variable du contexte appelant qui est "
"modifiée :"
#: ../Doc/faq/programming.rst:333
msgid "What are the rules for local and global variables in Python?"
msgstr ""
"Quelles sont les règles pour les variables locales et globales en Python ?"
#: ../Doc/faq/programming.rst:335
msgid ""
"In Python, variables that are only referenced inside a function are "
"implicitly global. If a variable is assigned a value anywhere within the "
"function's body, it's assumed to be a local unless explicitly declared as "
"global."
msgstr ""
"En Python, si une variable n'est pas modifiée dans une fonction mais "
"seulement lue, elle est implicitement considérée comme globale. Si une "
"valeur lui est affectée, elle est considérée locale (sauf si elle est "
"explicitement déclarée globale)."
#: ../Doc/faq/programming.rst:339
msgid ""
"Though a bit surprising at first, a moment's consideration explains this. "
"On one hand, requiring :keyword:`global` for assigned variables provides a "
"bar against unintended side-effects. On the other hand, if ``global`` was "
"required for all global references, you'd be using ``global`` all the time. "
"You'd have to declare as global every reference to a built-in function or to "
"a component of an imported module. This clutter would defeat the usefulness "
"of the ``global`` declaration for identifying side-effects."
msgstr ""
"Bien que surprenant au premier abord, ce choix s'explique facilement. D'une "
"part, exiger :keyword:`global` pour des variables affectées est une "
"protection contre des effets de bord inattendus. D'autre part, si ``global`` "
"était obligatoire pour toutes les références à des objets globaux, il "
"faudrait mettre ``global`` partout, car il faudrait dans ce cas déclarer "
"globale chaque référence à une fonction native ou à un composant d'un module "
"importé. Le codé serait alors truffé de déclarations ``global``, ce qui "
"nuirait à leur raison d'être : identifier les effets de bords."
#: ../Doc/faq/programming.rst:349
msgid ""
"Why do lambdas defined in a loop with different values all return the same "
"result?"
msgstr ""
"Pourquoi des expressions lambda définies dans une boucle avec des valeurs "
"différentes retournent-elles le même résultat ?"
#: ../Doc/faq/programming.rst:351
msgid ""
"Assume you use a for loop to define a few different lambdas (or even plain "
"functions), e.g.::"
msgstr ""
"Supposons que l'on utilise une boucle itérative pour définir des expressions "
"lambda (voire même des fonctions) différentes, par exemple ::"
#: ../Doc/faq/programming.rst:358
msgid ""
"This gives you a list that contains 5 lambdas that calculate ``x**2``. You "
"might expect that, when called, they would return, respectively, ``0``, "
"``1``, ``4``, ``9``, and ``16``. However, when you actually try you will "
"see that they all return ``16``::"
msgstr ""
"Le code précédent crée une liste de 5 expressions lambda qui calculent "
"chacune ``x**2``. En les exécutant, on pourrait s'attendre à obtenir ``0``, "
"``1``, ``4``, ``9`` et ``16``. Elles renvoient en réalité toutes ``16`` :"
#: ../Doc/faq/programming.rst:368
msgid ""
"This happens because ``x`` is not local to the lambdas, but is defined in "
"the outer scope, and it is accessed when the lambda is called --- not when "
"it is defined. At the end of the loop, the value of ``x`` is ``4``, so all "
"the functions now return ``4**2``, i.e. ``16``. You can also verify this by "
"changing the value of ``x`` and see how the results of the lambdas change::"
msgstr ""
"Ceci s'explique par le fait que ``x`` n'est pas une variable locale aux "
"expressions, mais est définie dans le contexte appelant. Elle est lue à "
"l'appel de l'expression lambda – et non au moment où cette expression est "
"définie. À la fin de la boucle, ``x`` vaut ``4``, donc toutes les fonctions "
"renvoient ``4*2``, i.e. ``16``. Ceci se vérifie également en changeant la "
"valeur de ``x`` et en constatant que les résultats sont modifiés :"
#: ../Doc/faq/programming.rst:378
msgid ""
"In order to avoid this, you need to save the values in variables local to "
"the lambdas, so that they don't rely on the value of the global ``x``::"
msgstr ""
"Pour éviter ce phénomène, les valeurs doivent être stockées dans des "
"variables locales aux expressions lambda pour que celles-ci ne se basent "
"plus sur la variable globale ``x`` :"
#: ../Doc/faq/programming.rst:385
msgid ""
"Here, ``n=x`` creates a new variable ``n`` local to the lambda and computed "
"when the lambda is defined so that it has the same value that ``x`` had at "
"that point in the loop. This means that the value of ``n`` will be ``0`` in "
"the first lambda, ``1`` in the second, ``2`` in the third, and so on. "
"Therefore each lambda will now return the correct result::"
msgstr ""
"Dans ce code, ``n=x`` crée une nouvelle variable ``n``, locale à "
"l'expression. Cette variable est évaluée quand l'expression est définie donc "
"``n`` a la même valeur que ``x`` à ce moment. La valeur de ``n`` est donc "
"``0`` dans la première lambda, ``1`` dans la deuxième, ``2`` dans la "
"troisième et ainsi de suite. Chaque expression lambda renvoie donc le "
"résultat correct :"
#: ../Doc/faq/programming.rst:396
msgid ""
"Note that this behaviour is not peculiar to lambdas, but applies to regular "
"functions too."
msgstr ""
"Ce comportement n'est pas propre aux expressions lambda, mais s'applique "
"aussi aux fonctions normales."
#: ../Doc/faq/programming.rst:401
msgid "How do I share global variables across modules?"
msgstr "Comment partager des variables globales entre modules ?"
#: ../Doc/faq/programming.rst:403
msgid ""
"The canonical way to share information across modules within a single "
"program is to create a special module (often called config or cfg). Just "
"import the config module in all modules of your application; the module then "
"becomes available as a global name. Because there is only one instance of "
"each module, any changes made to the module object get reflected "
"everywhere. For example:"
msgstr ""
"La manière standard de partager des informations entre modules d'un même "
"programme est de créer un module spécial (souvent appelé *config* ou *cfg*) "
"et de l'importer dans tous les modules de l'application ; le module devient "
"accessible depuis l'espace de nommage global. Vu qu'il n'y a qu'une instance "
"de chaque module, tout changement dans l'instance est propagé partout. Par "
"exemple :"
#: ../Doc/faq/programming.rst:409
msgid "config.py::"
msgstr "*config.py* ::"
#: ../Doc/faq/programming.rst:413
msgid "mod.py::"
msgstr "*mod.py* ::"
#: ../Doc/faq/programming.rst:418
msgid "main.py::"
msgstr "*main.py* ::"
#: ../Doc/faq/programming.rst:424
msgid ""
"Note that using a module is also the basis for implementing the Singleton "
"design pattern, for the same reason."
msgstr ""
"Pour les mêmes raisons, l'utilisation d'un module est aussi à la base de "
"l'implémentation du patron de conception singleton."
#: ../Doc/faq/programming.rst:429
msgid "What are the \"best practices\" for using import in a module?"
msgstr ""
"Quelles sont les « bonnes pratiques » pour utiliser import dans un module ?"
#: ../Doc/faq/programming.rst:431
msgid ""
"In general, don't use ``from modulename import *``. Doing so clutters the "
"importer's namespace, and makes it much harder for linters to detect "
"undefined names."
msgstr ""
"De manière générale, il ne faut pas faire ``from modulename import *``. Ceci "
"encombre l'espace de nommage de l'importateur et rend la détection de noms "
"non-définis beaucoup plus ardue pour les analyseurs de code."
#: ../Doc/faq/programming.rst:435
msgid ""
"Import modules at the top of a file. Doing so makes it clear what other "
"modules your code requires and avoids questions of whether the module name "
"is in scope. Using one import per line makes it easy to add and delete "
"module imports, but using multiple imports per line uses less screen space."
msgstr ""
"Les modules doivent être importés au début d'un fichier. Ceci permet "
"d'afficher clairement de quels modules le code à besoin et évite de se "
"demander si le module est dans le contexte. Faire un seul `import` par ligne "
"rend l'ajout et la suppression d'une importation de module plus aisé, mais "
"importer plusieurs modules sur une même ligne prend moins d'espace."
#: ../Doc/faq/programming.rst:440
msgid "It's good practice if you import modules in the following order:"
msgstr "Il est recommandé d'importer les modules dans l'ordre suivant :"
#: ../Doc/faq/programming.rst:442
msgid "standard library modules -- e.g. ``sys``, ``os``, ``getopt``, ``re``"
msgstr ""
"les modules de la bibliothèque standard — e.g. ``sys``, ``os``, ``getopt``, "
"``re``"
#: ../Doc/faq/programming.rst:443
msgid ""
"third-party library modules (anything installed in Python's site-packages "
"directory) -- e.g. mx.DateTime, ZODB, PIL.Image, etc."
msgstr ""
"les modules externes (tout ce qui est installé dans le dossier *site-"
"packages* de Python) — e.g. *mx.DateTime, ZODB, PIL.Image*, etc."
#: ../Doc/faq/programming.rst:445
msgid "locally-developed modules"
msgstr "les modules développés en local"
#: ../Doc/faq/programming.rst:447
msgid ""
"Only use explicit relative package imports. If you're writing code that's "
"in the ``package.sub.m1`` module and want to import ``package.sub.m2``, do "
"not just write ``import m2``, even though it's legal. Write ``from package."
"sub import m2`` or ``from . import m2`` instead."
msgstr ""
#: ../Doc/faq/programming.rst:452
msgid ""
"It is sometimes necessary to move imports to a function or class to avoid "
"problems with circular imports. Gordon McMillan says:"
msgstr ""
"Il est parfois nécessaire de déplacer des importations dans une fonction ou "
"une classe pour éviter les problèmes d'importations circulaires. Comme le "
"souligne Gordon McMillan :"
#: ../Doc/faq/programming.rst:455
msgid ""
"Circular imports are fine where both modules use the \"import <module>\" "
"form of import. They fail when the 2nd module wants to grab a name out of "
"the first (\"from module import name\") and the import is at the top level. "
"That's because names in the 1st are not yet available, because the first "
"module is busy importing the 2nd."
msgstr ""
"Il n'y a aucun souci à faire des importations circulaires tant que les deux "
"modules utilisent la forme \"import <module>\" . Ça ne pose problème que si "
"le second module cherche à récupérer un nom du premier module (*\"from "
"module import name\"*) et que l'importation est dans l'espace de nommage du "
"fichier. Les noms du premier module ne sont en effet pas encore disponibles "
"car le premier module est occupé à importer le second."
#: ../Doc/faq/programming.rst:461
msgid ""
"In this case, if the second module is only used in one function, then the "
"import can easily be moved into that function. By the time the import is "
"called, the first module will have finished initializing, and the second "
"module can do its import."
msgstr ""
"Dans ce cas, si le second module n'est utilisé que dans une fonction, "
"l'importation peut facilement être déplacée dans cette fonction. Au moment "
"où l'importation sera appelée, le premier module aura fini de s'initialiser "
"et le second pourra faire son importation."
#: ../Doc/faq/programming.rst:466
msgid ""
"It may also be necessary to move imports out of the top level of code if "
"some of the modules are platform-specific. In that case, it may not even be "
"possible to import all of the modules at the top of the file. In this case, "
"importing the correct modules in the corresponding platform-specific code is "
"a good option."
msgstr ""
"Il peut parfois être nécessaire de déplacer des importations de modules hors "
"de l'espace de plus haut niveau du code si certains de ces modules dépendent "
"de la machine utilisée. Dans ce cas de figure, il est parfois impossible "
"d'importer tous les modules au début du fichier. Dans ce cas, il est "
"recommandé d'importer les modules adéquats dans le code spécifique à la "
"machine."
#: ../Doc/faq/programming.rst:471
msgid ""
"Only move imports into a local scope, such as inside a function definition, "
"if it's necessary to solve a problem such as avoiding a circular import or "
"are trying to reduce the initialization time of a module. This technique is "
"especially helpful if many of the imports are unnecessary depending on how "
"the program executes. You may also want to move imports into a function if "
"the modules are only ever used in that function. Note that loading a module "
"the first time may be expensive because of the one time initialization of "
"the module, but loading a module multiple times is virtually free, costing "
"only a couple of dictionary lookups. Even if the module name has gone out "
"of scope, the module is probably available in :data:`sys.modules`."
msgstr ""
"Les imports ne devraient être déplacés dans un espace local, comme dans la "
"définition d'une fonction, que si cela est nécessaire pour résoudre un "
"problème comme éviter des dépendances circulaires ou réduire le temps "
"d'initialisation d'un module. Cette technique est particulièrement utile si "
"la majorité des imports est superflue selon le flux d'exécution du "
"programme. Il est également pertinent de déplacer des importations dans une "
"fonction si le module n'est utilisé qu'au sein de cette fonction. Le premier "
"chargement d'un module peut être coûteux à cause du coût fixe "
"d'initialisation d'un module, mais charger un module plusieurs fois est "
"quasiment gratuit, cela ne coûte que quelques indirections dans un "
"dictionnaire. Même si le nom du module est sorti du contexte courant, le "
"module est probablement disponible dans :data:`sys.modules`."
#: ../Doc/faq/programming.rst:484
msgid "Why are default values shared between objects?"
msgstr "Pourquoi les arguments par défaut sont-ils partagés entre les objets ?"
#: ../Doc/faq/programming.rst:486
msgid ""
"This type of bug commonly bites neophyte programmers. Consider this "
"function::"
msgstr ""
"C'est un problème que rencontrent souvent les programmeurs débutants. "
"Examinons la fonction suivante ::"
#: ../Doc/faq/programming.rst:493
msgid ""
"The first time you call this function, ``mydict`` contains a single item. "
"The second time, ``mydict`` contains two items because when ``foo()`` begins "
"executing, ``mydict`` starts out with an item already in it."
msgstr ""
"Au premier appel de cette fonction, ``mydict`` ne contient qu'un seul "
"élément. Au second appel, ``mydict`` contient deux éléments car quand "
"``foo()`` commence son exécution, ``mydict`` contient déjà un élément."
#: ../Doc/faq/programming.rst:497
msgid ""
"It is often expected that a function call creates new objects for default "
"values. This is not what happens. Default values are created exactly once, "
"when the function is defined. If that object is changed, like the "
"dictionary in this example, subsequent calls to the function will refer to "
"this changed object."
msgstr ""
"On est souvent amené à croire qu'un appel de fonction créé des nouveau "
"objets pour les valeurs par défaut. Ce n'est pas le cas. Les valeurs par "
"défaut ne sont créées qu'une et une seule fois, au moment où la fonction est "
"définie. Si l'objet est modifié, comme le dictionnaire dans cet exemple, les "
"appels suivants à cette fonction font référence à l'objet ainsi modifié."
#: ../Doc/faq/programming.rst:502
msgid ""
"By definition, immutable objects such as numbers, strings, tuples, and "
"``None``, are safe from change. Changes to mutable objects such as "
"dictionaries, lists, and class instances can lead to confusion."
msgstr ""
"Par définition, les objets immuables comme les nombres, les chaînes de "
"caractères, les n-uplets et ``None`` ne sont pas modifiés. Les changements "
"sur des objets muables comme les dictionnaires, les listes et les instances "
"de classe peuvent porter à confusion."
#: ../Doc/faq/programming.rst:506
msgid ""
"Because of this feature, it is good programming practice to not use mutable "
"objects as default values. Instead, use ``None`` as the default value and "
"inside the function, check if the parameter is ``None`` and create a new "
"list/dictionary/whatever if it is. For example, don't write::"
msgstr ""
"En raison de cette fonctionnalité, il vaut mieux ne pas utiliser d'objets "
"muables comme valeurs par défaut. Il vaut mieux utiliser ``None`` comme "
"valeur par défaut et, à l'intérieur de la fonction, vérifier si le paramètre "
"est à ``None`` et créer une nouvelle liste, dictionnaire ou autre, le cas "
"échéant. Par exemple, il ne faut pas écrire ::"
#: ../Doc/faq/programming.rst:514
msgid "but::"
msgstr "mais plutôt ::"
#: ../Doc/faq/programming.rst:520
msgid ""
"This feature can be useful. When you have a function that's time-consuming "
"to compute, a common technique is to cache the parameters and the resulting "
"value of each call to the function, and return the cached value if the same "
"value is requested again. This is called \"memoizing\", and can be "
"implemented like this::"
msgstr ""
"Cette fonctionnalité a une utilité. Il est courant de mettre en cache les "
"paramètres et la valeur de retour de chacun des appels d'une fonction "
"coûteuse à exécuter, et de renvoyer la valeur stockée en cache si le même "
"appel est ré-effectué. C'est la technique dite de « mémoïsation », qui "
"s'implémente de la manière suivante ::"
#: ../Doc/faq/programming.rst:535
msgid ""
"You could use a global variable containing a dictionary instead of the "
"default value; it's a matter of taste."
msgstr ""
"Il est possible d'utiliser une variable globale contenant un dictionnaire à "
"la place de la valeur par défaut ; ce n'est qu'une question de goût."
#: ../Doc/faq/programming.rst:540
msgid ""
"How can I pass optional or keyword parameters from one function to another?"
msgstr ""
"Comment passer des paramètres optionnels ou nommés d'une fonction à l'autre ?"
#: ../Doc/faq/programming.rst:542
msgid ""
"Collect the arguments using the ``*`` and ``**`` specifiers in the "
"function's parameter list; this gives you the positional arguments as a "
"tuple and the keyword arguments as a dictionary. You can then pass these "
"arguments when calling another function by using ``*`` and ``**``::"
msgstr ""
"Il faut récupérer les arguments en utilisant les sélecteurs ``*`` et ``**`` "
"dans la liste des paramètres de la fonction ; ceci donne les arguments "
"positionnels sous la forme d'un n-uplet et les arguments nommés sous forme "
"de dictionnaire. Ces arguments peuvent être passés à une autre fonction en "
"utilisant ``*`` et ``**`` ::"
#: ../Doc/faq/programming.rst:553
msgid ""
"In the unlikely case that you care about Python versions older than 2.0, "
"use :func:`apply`::"
msgstr ""
#: ../Doc/faq/programming.rst:570
msgid "What is the difference between arguments and parameters?"
msgstr "Quelle est la différence entre les arguments et les paramètres ?"
#: ../Doc/faq/programming.rst:572
msgid ""
":term:`Parameters <parameter>` are defined by the names that appear in a "
"function definition, whereas :term:`arguments <argument>` are the values "
"actually passed to a function when calling it. Parameters define what types "
"of arguments a function can accept. For example, given the function "
"definition::"
msgstr ""
"Les :term:`paramètres <parameter>` sont les noms qui apparaissent dans une "
"définition de fonction, alors que les :term:`arguments <argument>` sont les "
"valeurs qui sont réellement passées à une fonction lors de l'appel de celle-"
"ci. Les paramètres définissent les types des arguments qu'une fonction "
"accepte. Ainsi, avec la définition de fonction suivante ::"
#: ../Doc/faq/programming.rst:580
msgid ""
"*foo*, *bar* and *kwargs* are parameters of ``func``. However, when calling "
"``func``, for example::"
msgstr ""
"*foo*, *bar* et *kwargs* sont des paramètres de ``func``. Mais à l'appel de "
"``func`` avec, par exemple ::"
#: ../Doc/faq/programming.rst:585
msgid "the values ``42``, ``314``, and ``somevar`` are arguments."
msgstr "les valeurs ``42``, ``314``, et ``somevar`` sont des arguments."
#: ../Doc/faq/programming.rst:589
msgid "Why did changing list 'y' also change list 'x'?"
msgstr "Pourquoi modifier la liste 'y' modifie aussi la liste 'x' ?"
#: ../Doc/faq/programming.rst:591
msgid "If you wrote code like::"
msgstr "Si vous avez écrit du code comme : ::"
#: ../Doc/faq/programming.rst:601
msgid ""
"you might be wondering why appending an element to ``y`` changed ``x`` too."
msgstr ""
"vous vous demandez peut-être pourquoi l'ajout d'un élément à ``y`` a aussi "
"changé ``x``."
#: ../Doc/faq/programming.rst:603
msgid "There are two factors that produce this result:"
msgstr "Il y a deux raisons qui conduisent à ce comportement :"
#: ../Doc/faq/programming.rst:605
msgid ""
"Variables are simply names that refer to objects. Doing ``y = x`` doesn't "
"create a copy of the list -- it creates a new variable ``y`` that refers to "
"the same object ``x`` refers to. This means that there is only one object "
"(the list), and both ``x`` and ``y`` refer to it."
msgstr ""
"Les variables ne sont que des noms qui font référence à des objets. La ligne "
"``y = x`` ne crée pas une copie de la liste — elle crée une nouvelle "
"variable ``y`` qui pointe sur le même objet que ``x``. Ceci signifie qu'il "
"n'existe qu'un seul objet (la liste) auquel ``x`` et ``y`` font référence."
#: ../Doc/faq/programming.rst:609
msgid ""
"Lists are :term:`mutable`, which means that you can change their content."
msgstr ""
"Les listes sont des :term:`muable`, ce qui signifie que leur contenu peut "
"être modifié."
#: ../Doc/faq/programming.rst:611
msgid ""
"After the call to :meth:`~list.append`, the content of the mutable object "
"has changed from ``[]`` to ``[10]``. Since both the variables refer to the "
"same object, using either name accesses the modified value ``[10]``."
msgstr ""
"Après l'appel de :meth:`~list.append`, le contenu de l'objet muable est "
"passé de ``[]`` à ``[10]``. Vu que les deux variables font référence au même "
"objet, il est possible d'accéder à la valeur modifiée ``[10]`` avec chacun "
"des noms."
#: ../Doc/faq/programming.rst:615
msgid "If we instead assign an immutable object to ``x``::"
msgstr "Si au contraire, on affecte un objet immuable à ``x`` ::"
#: ../Doc/faq/programming.rst:625
msgid ""
"we can see that in this case ``x`` and ``y`` are not equal anymore. This is "
"because integers are :term:`immutable`, and when we do ``x = x + 1`` we are "
"not mutating the int ``5`` by incrementing its value; instead, we are "
"creating a new object (the int ``6``) and assigning it to ``x`` (that is, "
"changing which object ``x`` refers to). After this assignment we have two "
"objects (the ints ``6`` and ``5``) and two variables that refer to them "
"(``x`` now refers to ``6`` but ``y`` still refers to ``5``)."
msgstr ""
"on observe que ``x`` et ``y`` ne sont ici plus égales. Les entiers sont des "
"immuables (:term:`immutable`), et ``x = x + 1`` ne change pas l'entier ``5`` "
"en incrémentant sa valeur. Au contraire, un nouvel objet est créé (l'entier "
"``6``) et affecté à ``x`` (c'est à dire qu'on change l'objet auquel fait "
"référence ``x``). Après cette affectation on a deux objets (les entiers "