FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-docs-de/faq/programming.po at 3.15 · python/python-docs-de · GitHub
python
python-docs-de
Repository navigation
Code
Issues
Pull requests
2
(2)
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
python-docs-de
/
faq
/
programming.po
Copy path
More file actions
More file actions
Latest commit
History
History
History
4885 lines (4379 loc) · 181 KB
Breadcrumbs
python-docs-de
/
faq
/
programming.po
Copy path
File metadata and controls
4885 lines (4379 loc) · 181 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
German translation of the Python documentation.
#
Copyright (C) 2001 Python Software Foundation
#
This file is distributed under the same license as the Python package.
#
#
Translators:
#
python-doc bot, 2025
#
Swen Bachmann, 2026
#
msgid ""
msgstr ""
"
Project-Id-Version
:
Python 3.15\n
"
"
Report-Msgid-Bugs-To
:
\n
"
"
POT-Creation-Date
:
2026-09-14 20:17+0000\n
"
"
PO-Revision-Date
:
2026-10-19 22:30+0200\n
"
"
Last-Translator
:
python-doc bot, 2025\n
"
"
Language-Team
:
German (https://github.com/python/python-docs-de)\n
"
"
Language
:
de\n
"
"
MIME-Version
:
1.0\n
"
"
Content-Type
:
text/plain; charset=UTF-8\n
"
"
Content-Transfer-Encoding
:
8bit\n
"
"
Plural-Forms
:
nplurals=2; plural=(n != 1);\n
"
#:
../../faq/programming.rst:5
msgid
"Programming FAQ"
msgstr
"FAQ zum Programmieren"
#:
../../faq/programming.rst:8
msgid
"Contents"
msgstr
"Inhalt"
#:
../../faq/programming.rst:12
msgid
"General questions"
msgstr
"Allgemeine Fragen"
#:
../../faq/programming.rst:15
msgid
""
"Is there a source code-level debugger with breakpoints and single-stepping?"
msgstr
""
"Gibt es einen Debugger auf Quellcode-Ebene mit Haltepunkten und "
"Einzelschrittausführung?"
#:
../../faq/programming.rst:17
../../faq/programming.rst:56
msgid
"Yes."
msgstr
"Ja."
#:
../../faq/programming.rst:19
msgid
""
"Several debuggers for Python are described below, and the built-in function :"
"func:`breakpoint` allows you to drop into any of them."
msgstr
""
"Unten sind mehrere Debugger für Python beschrieben, und die integrierte "
"Funktion :func:`breakpoint` erlaubt dir, in jeden davon einzusteigen."
#:
../../faq/programming.rst:22
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
""
"Das Modul pdb ist ein einfacher, aber ausreichender Debugger für Python im "
"Konsolenbetrieb. Es ist Teil der Python-Standardbibliothek und :mod:`im "
"Referenzhandbuch der Bibliothek dokumentiert <pdb>`. Du kannst auch deinen "
"eigenen Debugger schreiben und dir den Code von pdb als Beispiel nehmen."
#:
../../faq/programming.rst:27
msgid
""
"The IDLE interactive development environment, which is part of the standard "
"Python distribution (normally available as :mod:`idlelib`), includes a "
"graphical debugger."
msgstr
""
"Die interaktive Entwicklungsumgebung IDLE, die Teil der Standarddistribution "
"von Python ist (normalerweise als :mod:`idlelib` verfügbar), enthält einen "
"graphischen Debugger."
#:
../../faq/programming.rst:31
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 "
"`pywin32 <https://github.com/mhammond/pywin32>`_ project and as a part of "
"the `ActivePython <https://www.activestate.com/products/python/>`_ "
"distribution."
msgstr
""
"PythonWin ist eine Python-IDE mit einem graphischen Debugger auf Basis von "
"pdb. Der Debugger von PythonWin färbt Haltepunkte ein und hat eine Reihe "
"praktischer Eigenschaften, etwa das Debuggen von Programmen außerhalb von "
"PythonWin. PythonWin ist als Teil des Projekts `pywin32 <https://github.com/"
"mhammond/pywin32>`_ und als Teil der Distribution `ActivePython <https://www."
"activestate.com/products/python/>`_ verfügbar."
#:
../../faq/programming.rst:38
msgid
""
"`Eric <https://eric-ide.python-projects.org/>`_ is an IDE built on PyQt and "
"the Scintilla editing component."
msgstr
""
"`Eric <https://eric-ide.python-projects.org/>`_ ist eine IDE, die auf PyQt "
"und der Editor-Komponente Scintilla aufbaut."
#:
../../faq/programming.rst:41
msgid
""
"`trepan3k <https://github.com/rocky/python3-trepan/>`_ is a gdb-like "
"debugger."
msgstr
""
"`trepan3k <https://github.com/rocky/python3-trepan/>`_ ist ein Debugger im "
"Stil von gdb."
#:
../../faq/programming.rst:43
msgid
""
"`Visual Studio Code <https://code.visualstudio.com/>`_ is an IDE with "
"debugging tools that integrates with version-control software."
msgstr
""
"`Visual Studio Code <https://code.visualstudio.com/>`_ ist eine IDE mit "
"Debugging-Werkzeugen, die sich in Versionsverwaltungen integriert."
#:
../../faq/programming.rst:46
msgid
""
"There are a number of commercial Python IDEs that include graphical "
"debuggers. They include:"
msgstr
""
"Es gibt eine Reihe kommerzieller Python-IDEs mit graphischen Debuggern. Dazu "
"gehören:"
#:
../../faq/programming.rst:49
msgid
"`Wing IDE <https://wingware.com/>`_"
msgstr
"`Wing IDE <https://wingware.com/>`_"
#:
../../faq/programming.rst:50
msgid
"`PyCharm <https://www.jetbrains.com/pycharm/>`_"
msgstr
"`PyCharm <https://www.jetbrains.com/pycharm/>`_"
#:
../../faq/programming.rst:54
msgid
"Are there tools to help find bugs or perform static analysis?"
msgstr
""
"Gibt es Werkzeuge, die beim Finden von Fehlern oder bei statischer Analyse "
"helfen?"
#:
../../faq/programming.rst:58
msgid
""
"`Ruff <https://docs.astral.sh/ruff/>`__, `Pylint <https://pylint.readthedocs."
"io/>`__ and `Pyflakes <https://github.com/PyCQA/pyflakes>`__ do basic "
"checking that will help you catch bugs sooner."
msgstr
""
"`Ruff <https://docs.astral.sh/ruff/>`__, `Pylint <https://pylint.readthedocs."
"io/>`__ und `Pyflakes <https://github.com/PyCQA/pyflakes>`__ führen "
"grundlegende Prüfungen durch, mit denen du Fehler früher findest."
#:
../../faq/programming.rst:63
msgid
""
"Static type checkers such as `mypy <https://mypy-lang.org/>`__, `ty <https://"
"docs.astral.sh/ty/>`__, `Pyrefly <https://pyrefly.org/>`__, and `pytype "
"<https://github.com/google/pytype>`__ can check type hints in Python source "
"code."
msgstr
""
"Statische Typprüfer wie `mypy <https://mypy-lang.org/>`__, `ty <https://docs."
"astral.sh/ty/>`__, `Pyrefly <https://pyrefly.org/>`__ und `pytype <https://"
"github.com/google/pytype>`__ können Typhinweise im Python-Quellcode prüfen."
#:
../../faq/programming.rst:73
msgid
"How can I create a stand-alone binary from a Python script?"
msgstr
"Wie erzeuge ich aus einem Python-Skript eine eigenständige Binärdatei?"
#:
../../faq/programming.rst:75
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
""
"Du brauchst Python nicht nach C-Code kompilieren zu können, wenn du nur ein "
"eigenständiges Programm willst, das Nutzer herunterladen und ausführen "
"können, ohne vorher die Python-Distribution zu installieren. Es gibt eine "
"Reihe von Werkzeugen, die den von einem Programm benötigten Satz an Modulen "
"bestimmen und diese Module mit einer Python-Binärdatei zu einer einzigen "
"ausführbaren Datei zusammenbinden."
#:
../../faq/programming.rst:81
msgid
""
"One is to use the freeze tool, which is included in the Python source tree "
"as :source:`Tools/freeze`. It converts Python byte code to C arrays; with a "
"C compiler you can embed all your modules into a new program, which is then "
"linked with the standard Python modules."
msgstr
""
"Eines davon ist das Werkzeug freeze, das im Python-Quellbaum unter :source:"
"`Tools/freeze` enthalten ist. Es wandelt Python-Bytecode in C-Arrays um. Mit "
"einem C-Compiler kannst du dann alle deine Module in ein neues Programm "
"einbetten, das anschließend mit den Standardmodulen von Python gelinkt wird."
#:
../../faq/programming.rst:87
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
""
"Es arbeitet so, dass es deinen Quellcode rekursiv nach Import-Anweisungen "
"durchsucht (in beiden Formen) und die Module sowohl im Standardsuchpfad von "
"Python als auch im Quellverzeichnis sucht (für integrierte Module). "
"Anschließend wandelt es den Bytecode der in Python geschriebenen Module in C-"
"Code um (Array-Initialisierer, die sich mit dem Modul marshal in Codeobjekte "
"verwandeln lassen) und erzeugt eine maßgeschneiderte Konfigurationsdatei, "
"die nur jene integrierten Module enthält, die im Programm tatsächlich "
"verwendet werden. Dann kompiliert es den erzeugten C-Code und linkt ihn mit "
"dem Rest des Python-Interpreters zu einer eigenständigen Binärdatei, die "
"sich genau wie dein Skript verhält."
#:
../../faq/programming.rst:96
msgid
""
"The following packages can help with the creation of console and GUI "
"executables:"
msgstr
""
"Die folgenden Pakete helfen beim Erzeugen von ausführbaren Dateien für "
"Konsole und graphische Oberfläche:"
#:
../../faq/programming.rst:99
msgid
"`Nuitka <https://nuitka.net/>`_ (Cross-platform)"
msgstr
"`Nuitka <https://nuitka.net/>`_ (plattformübergreifend)"
#:
../../faq/programming.rst:100
msgid
"`PyInstaller <https://pyinstaller.org/>`_ (Cross-platform)"
msgstr
"`PyInstaller <https://pyinstaller.org/>`_ (plattformübergreifend)"
#:
../../faq/programming.rst:101
msgid
""
"`PyOxidizer <https://pyoxidizer.readthedocs.io/en/stable/>`_ (Cross-platform)"
msgstr
""
"`PyOxidizer <https://pyoxidizer.readthedocs.io/en/stable/>`_ "
"(plattformübergreifend)"
#:
../../faq/programming.rst:102
msgid
""
"`cx_Freeze <https://marcelotduarte.github.io/cx_Freeze/>`_ (Cross-platform)"
msgstr
""
"`cx_Freeze <https://marcelotduarte.github.io/cx_Freeze/>`_ "
"(plattformübergreifend)"
#:
../../faq/programming.rst:103
msgid
"`py2app <https://github.com/ronaldoussoren/py2app>`_ (macOS only)"
msgstr
"`py2app <https://github.com/ronaldoussoren/py2app>`_ (nur macOS)"
#:
../../faq/programming.rst:104
msgid
"`py2exe <https://www.py2exe.org/>`_ (Windows only)"
msgstr
"`py2exe <https://www.py2exe.org/>`_ (nur Windows)"
#:
../../faq/programming.rst:108
msgid
"Are there coding standards or a style guide for Python programs?"
msgstr
""
"Gibt es Kodierungsstandards oder einen Stilleitfaden für Python-Programme?"
#:
../../faq/programming.rst:110
msgid
""
"Yes. The coding style required for standard library modules is documented "
"as :pep:`8`."
msgstr
""
"Ja. Der für Module der Standardbibliothek verlangte Programmierstil ist in :"
"pep:`8` dokumentiert."
#:
../../faq/programming.rst:115
msgid
"Core language"
msgstr
"Kernsprache"
#:
../../faq/programming.rst:120
msgid
"Why am I getting an UnboundLocalError when the variable has a value?"
msgstr
""
"Warum erhalte ich einen UnboundLocalError, obwohl die Variable einen Wert "
"hat?"
#:
../../faq/programming.rst:122
msgid
""
"It can be a surprise to get the :exc:`UnboundLocalError` in previously "
"working code when it is modified by adding an assignment statement somewhere "
"in the body of a function."
msgstr
""
"Es kann überraschen, in vorher funktionierendem Code einen :exc:"
"`UnboundLocalError` zu erhalten, nachdem er durch eine Zuweisung irgendwo im "
"Rumpf einer Funktion verändert wurde."
#:
../../faq/programming.rst:126
msgid
"This code:"
msgstr
"Dieser Code:"
#:
../../faq/programming.rst:135
msgid
"works, but this code:"
msgstr
"funktioniert, aber dieser Code:"
#:
../../faq/programming.rst:142
msgid
"results in an :exc:`!UnboundLocalError`:"
msgstr
"führt zu einem :exc:`!UnboundLocalError`:"
#:
../../faq/programming.rst:149
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
""
"Das liegt daran, dass eine Variable, der du in einem Gültigkeitsbereich "
"etwas zuweist, lokal zu diesem Bereich wird und jede gleichnamige Variable "
"im äußeren Bereich verdeckt. Da die letzte Anweisung in foo ``x`` einen "
"neuen Wert zuweist, erkennt der Compiler ``x`` als lokale Variable. Folglich "
"versucht das vorangehende ``print(x)``, die nicht initialisierte lokale "
"Variable auszugeben, und es kommt zu einem Fehler."
#:
../../faq/programming.rst:156
msgid
""
"In the example above you can access the outer scope variable by declaring it "
"global:"
msgstr
""
"Im Beispiel oben kannst du auf die Variable des äußeren Bereichs zugreifen, "
"indem du sie als global deklarierst:"
#:
../../faq/programming.rst:168
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
""
"Diese ausdrückliche Deklaration ist nötig, um dich daran zu erinnern, dass "
"du (anders als in der oberflächlich ähnlichen Situation mit Klassen- und "
"Instanzvariablen) tatsächlich den Wert der Variablen im äußeren Bereich "
"änderst:"
#:
../../faq/programming.rst:175
msgid
""
"You can do a similar thing in a nested scope using the :keyword:`nonlocal` "
"keyword:"
msgstr
""
"Etwas Ähnliches kannst du in einem verschachtelten Gültigkeitsbereich mit "
"dem Schlüsselwort :keyword:`nonlocal` tun:"
#:
../../faq/programming.rst:193
msgid
"What are the rules for local and global variables in Python?"
msgstr
"Welche Regeln gelten in Python für lokale und globale Variablen?"
#:
../../faq/programming.rst:195
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
""
"In Python sind Variablen, die innerhalb einer Funktion nur gelesen werden, "
"implizit global. Wird einer Variablen irgendwo im Rumpf der Funktion ein "
"Wert zugewiesen, gilt sie als lokal, sofern sie nicht ausdrücklich als "
"global deklariert ist."
#:
../../faq/programming.rst:199
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
""
"Das überrascht zunächst etwas, erklärt sich aber nach kurzem Nachdenken. Zum "
"einen schützt die Pflicht, :keyword:`global` für zugewiesene Variablen "
"anzugeben, vor unbeabsichtigten Nebenwirkungen. Zum anderen müsstest du "
"``global`` ständig verwenden, wenn es für alle globalen Zugriffe nötig wäre. "
"Du müsstest jeden Zugriff auf eine integrierte Funktion oder auf einen "
"Bestandteil eines importierten Moduls als global deklarieren. Dieses "
"Durcheinander würde den Nutzen der ``global``-Deklaration zum Erkennen von "
"Nebenwirkungen zunichtemachen."
#:
../../faq/programming.rst:209
msgid
""
"Why do lambdas defined in a loop with different values all return the same "
"result?"
msgstr
""
"Warum geben Lambdas, die in einer Schleife mit verschiedenen Werten "
"definiert wurden, alle dasselbe Ergebnis zurück?"
#:
../../faq/programming.rst:211
msgid
""
"Assume you use a for loop to define a few different lambdas (or even plain "
"functions), for example::"
msgstr
""
"Nimm an, du definierst mit einer for-Schleife einige verschiedene Lambdas "
"(oder auch gewöhnliche Funktionen), zum Beispiel::"
#:
../../faq/programming.rst:214
msgid
""
">>> squares = []\n"
">>> for x in range(5):\n"
"... squares.append(lambda: x**2)"
msgstr
""
">>> squares = []\n"
">>> for x in range(5):\n"
"... squares.append(lambda: x**2)"
#:
../../faq/programming.rst:218
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
""
"Das ergibt eine Liste mit 5 Lambdas, die ``x**2`` berechnen. Du würdest "
"erwarten, dass sie beim Aufruf jeweils ``0``, ``1``, ``4``, ``9`` und ``16`` "
"zurückgeben. Wenn du es aber ausprobierst, siehst du, dass alle ``16`` "
"zurückgeben::"
#:
../../faq/programming.rst:223
msgid
""
">>> squares[2]()\n"
"16\n"
">>> squares[4]()\n"
"16"
msgstr
""
">>> squares[2]()\n"
"16\n"
">>> squares[4]()\n"
"16"
#:
../../faq/programming.rst:228
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``, that is ``16``. You can also verify this "
"by changing the value of ``x`` and see how the results of the lambdas "
"change::"
msgstr
""
"Das passiert, weil ``x`` nicht lokal zu den Lambdas ist, sondern im äußeren "
"Gültigkeitsbereich definiert wird, und weil darauf beim Aufruf des Lambdas "
"zugegriffen wird --- nicht bei seiner Definition. Am Ende der Schleife ist "
"der Wert von ``x`` gleich ``4``, deshalb geben jetzt alle Funktionen "
"``4**2`` zurück, also ``16``. Du kannst das auch prüfen, indem du den Wert "
"von ``x`` änderst und siehst, wie sich die Ergebnisse der Lambdas ändern::"
#:
../../faq/programming.rst:234
msgid
""
">>> x = 8\n"
">>> squares[2]()\n"
"64"
msgstr
""
">>> x = 8\n"
">>> squares[2]()\n"
"64"
#:
../../faq/programming.rst:238
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
""
"Um das zu vermeiden, musst du die Werte in Variablen speichern, die lokal zu "
"den Lambdas sind, damit sie nicht vom Wert des globalen ``x`` abhängen::"
#:
../../faq/programming.rst:241
msgid
""
">>> squares = []\n"
">>> for x in range(5):\n"
"... squares.append(lambda n=x: n**2)"
msgstr
""
">>> squares = []\n"
">>> for x in range(5):\n"
"... squares.append(lambda n=x: n**2)"
#:
../../faq/programming.rst:245
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
""
"Hier erzeugt ``n=x`` eine neue Variable ``n``, die lokal zum Lambda ist und "
"bei der Definition des Lambdas berechnet wird, sodass sie denselben Wert "
"hat, den ``x`` an dieser Stelle der Schleife hatte. Das bedeutet, dass der "
"Wert von ``n`` im ersten Lambda ``0`` ist, im zweiten ``1``, im dritten "
"``2`` und so weiter. Deshalb gibt jedes Lambda jetzt das richtige Ergebnis "
"zurück::"
#:
../../faq/programming.rst:251
msgid
""
">>> squares[2]()\n"
"4\n"
">>> squares[4]()\n"
"16"
msgstr
""
">>> squares[2]()\n"
"4\n"
">>> squares[4]()\n"
"16"
#:
../../faq/programming.rst:256
msgid
""
"Note that this behaviour is not peculiar to lambdas, but applies to regular "
"functions too."
msgstr
""
"Beachte, dass dieses Verhalten nicht auf Lambdas beschränkt ist, sondern "
"genauso für gewöhnliche Funktionen gilt."
#:
../../faq/programming.rst:261
msgid
"How do I share global variables across modules?"
msgstr
"Wie teile ich globale Variablen über Module hinweg?"
#:
../../faq/programming.rst:263
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
""
"Der übliche Weg, Informationen innerhalb eines Programms über Module hinweg "
"zu teilen, ist ein eigenes Modul (oft config oder cfg genannt). Importiere "
"das Modul config einfach in allen Modulen deiner Anwendung. Das Modul steht "
"dann als globaler Name zur Verfügung. Weil es von jedem Modul nur eine "
"Instanz gibt, wirken sich alle Änderungen am Modulobjekt überall aus. Zum "
"Beispiel:"
#:
../../faq/programming.rst:269
msgid
"config.py::"
msgstr
"config.py::"
#:
../../faq/programming.rst:271
msgid
"x = 0 # Default value of the 'x' configuration setting"
msgstr
"x = 0 # Voreingestellter Wert der Konfigurationseinstellung 'x'"
#:
../../faq/programming.rst:273
msgid
"mod.py::"
msgstr
"mod.py::"
#:
../../faq/programming.rst:275
msgid
""
"import config\n"
"config.x = 1"
msgstr
""
"import config\n"
"config.x = 1"
#:
../../faq/programming.rst:278
msgid
"main.py::"
msgstr
"main.py::"
#:
../../faq/programming.rst:280
msgid
""
"import config\n"
"import mod\n"
"print(config.x)"
msgstr
""
"import config\n"
"import mod\n"
"print(config.x)"
#:
../../faq/programming.rst:284
msgid
""
"Note that using a module is also the basis for implementing the singleton "
"design pattern, for the same reason."
msgstr
""
"Beachte, dass ein Modul aus demselben Grund auch die Grundlage dafür ist, "
"das Entwurfsmuster Singleton umzusetzen."
#:
../../faq/programming.rst:289
msgid
"What are the
\"
best practices
\"
for using import in a module?"
msgstr
""
"Was sind die „besten Vorgehensweisen“ für die Verwendung von import in einem "
"Modul?"
#:
../../faq/programming.rst:291
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
""
"Verwende im Allgemeinen nicht ``from modulename import *``. Das überfüllt "
"den Namensraum des Importierenden und macht es Lintern deutlich schwerer, "
"undefinierte Namen zu erkennen."
#:
../../faq/programming.rst:295
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
""
"Importiere Module am Anfang einer Datei. Das macht deutlich, welche anderen "
"Module dein Code benötigt, und erspart die Frage, ob der Modulname im "
"Gültigkeitsbereich liegt. Ein Import pro Zeile macht es einfach, "
"Modulimporte hinzuzufügen und zu löschen, mehrere Importe pro Zeile brauchen "
"dagegen weniger Platz auf dem Bildschirm."
#:
../../faq/programming.rst:300
msgid
"It's good practice if you import modules in the following order:"
msgstr
""
"Es ist gute Praxis, Module in der folgenden Reihenfolge zu importieren:"
#:
../../faq/programming.rst:302
msgid
""
"standard library modules -- such as :mod:`sys`, :mod:`os`, :mod:`argparse`, :"
"mod:`re`"
msgstr
""
"Module der Standardbibliothek -- etwa :mod:`sys`, :mod:`os`, :mod:"
"`argparse`, :mod:`re`"
#:
../../faq/programming.rst:303
msgid
""
"third-party library modules (anything installed in Python's site-packages "
"directory) -- such as :pypi:`dateutil`, :pypi:`requests`, :pypi:`tzdata`"
msgstr
""
"Module von Fremdbibliotheken (alles, was im Verzeichnis site-packages von "
"Python installiert ist) -- etwa :pypi:`dateutil`, :pypi:`requests`, :pypi:"
"`tzdata`"
#:
../../faq/programming.rst:305
msgid
"locally developed modules"
msgstr
"selbst entwickelte Module"
#:
../../faq/programming.rst:307
msgid
""
"It is sometimes necessary to move imports to a function or class to avoid "
"problems with circular imports. Gordon McMillan says:"
msgstr
""
"Manchmal ist es nötig, Importe in eine Funktion oder Klasse zu verschieben, "
"um Probleme mit zirkulären Importen zu vermeiden. Gordon McMillan sagt dazu:"
#:
../../faq/programming.rst:310
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
""
"Zirkuläre Importe sind in Ordnung, wenn beide Module die Form „import "
"<module>“ verwenden. Sie scheitern, wenn das zweite Modul einen Namen aus "
"dem ersten holen will („from module import name“) und der Import auf der "
"obersten Ebene steht. Das liegt daran, dass die Namen im ersten Modul noch "
"nicht verfügbar sind, weil das erste Modul gerade damit beschäftigt ist, das "
"zweite zu importieren."
#:
../../faq/programming.rst:316
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
""
"Wird das zweite Modul in diesem Fall nur in einer Funktion verwendet, lässt "
"sich der Import leicht in diese Funktion verschieben. Wenn der Import dann "
"aufgerufen wird, hat das erste Modul seine Initialisierung abgeschlossen, "
"und das zweite Modul kann seinen Import durchführen."
#:
../../faq/programming.rst:321
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
""
"Es kann außerdem nötig sein, Importe aus der obersten Ebene des Codes "
"herauszuholen, wenn einige der Module plattformspezifisch sind. In diesem "
"Fall ist es womöglich gar nicht möglich, alle Module am Anfang der Datei zu "
"importieren. Dann ist es eine gute Lösung, die richtigen Module im jeweils "
"zugehörigen plattformspezifischen Code zu importieren."
#:
../../faq/programming.rst:326
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
""
"Verschiebe Importe nur dann in einen lokalen Gültigkeitsbereich, etwa in "
"eine Funktionsdefinition, wenn es nötig ist, um ein Problem wie einen "
"zirkulären Import zu lösen, oder wenn du die Initialisierungszeit eines "
"Moduls verkürzen willst. Diese Technik hilft besonders dann, wenn viele der "
"Importe je nach Programmablauf gar nicht gebraucht werden. Vielleicht willst "
"du Importe auch dann in eine Funktion verschieben, wenn die Module "
"ausschließlich in dieser Funktion verwendet werden. Beachte, dass das erste "
"Laden eines Moduls wegen der einmaligen Initialisierung teuer sein kann, ein "
"Modul mehrfach zu laden aber praktisch kostenlos ist und nur ein paar "
"Suchvorgänge im Dictionary kostet. Selbst wenn der Modulname den "
"Gültigkeitsbereich verlassen hat, ist das Modul wahrscheinlich noch über :"
"data:`sys.modules` verfügbar."
#:
../../faq/programming.rst:339
msgid
"Why are default values shared between objects?"
msgstr
"Warum werden Vorgabewerte zwischen Objekten geteilt?"
#:
../../faq/programming.rst:341
msgid
""
"This type of bug commonly bites neophyte programmers. Consider this "
"function::"
msgstr
""
"Diese Art von Fehler erwischt Programmieranfänger häufig. Sieh dir diese "
"Funktion an::"
#:
../../faq/programming.rst:343
msgid
""
"def foo(mydict={}): # Danger: shared reference to one dict for all calls\n"
" ... compute something ...\n"
" mydict[key] = value\n"
" return mydict"
msgstr
""
"def foo(mydict={}): # Gefahr: gemeinsame Referenz auf ein Dictionary für "
"alle Aufrufe\n"
" ... compute something ...\n"
" mydict[key] = value\n"
" return mydict"
#:
../../faq/programming.rst:348
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
""
"Beim ersten Aufruf dieser Funktion enthält ``mydict`` einen einzigen "
"Eintrag. Beim zweiten enthält ``mydict`` zwei Einträge, weil ``mydict`` beim "
"Start von ``foo()`` bereits einen Eintrag enthält."
#:
../../faq/programming.rst:352
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
""
"Oft wird erwartet, dass ein Funktionsaufruf neue Objekte für die "
"Vorgabewerte erzeugt. Das ist nicht der Fall. Vorgabewerte werden genau "
"einmal erzeugt, nämlich bei der Definition der Funktion. Wird dieses Objekt "
"verändert, wie das Dictionary in diesem Beispiel, beziehen sich nachfolgende "
"Aufrufe der Funktion auf das veränderte Objekt."
#:
../../faq/programming.rst:357
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
""
"Unveränderliche Objekte wie Zahlen, Zeichenketten, Tupel und ``None`` sind "
"schon per Definition vor Änderungen sicher. Änderungen an veränderlichen "
"Objekten wie Dictionarys, Listen und Klasseninstanzen können dagegen zu "
"Verwirrung führen."
#:
../../faq/programming.rst:361
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
""
"Wegen dieser Eigenschaft ist es guter Programmierstil, keine veränderlichen "
"Objekte als Vorgabewerte zu verwenden. Nimm stattdessen ``None`` als "
"Vorgabewert und prüfe innerhalb der Funktion, ob der Parameter ``None`` ist, "
"um in diesem Fall eine neue Liste, ein neues Dictionary oder was auch immer "
"zu erzeugen. Schreibe zum Beispiel nicht::"
#:
../../faq/programming.rst:366
msgid
""
"def foo(mydict={}):\n"
" ..."
msgstr
""
"def foo(mydict={}):\n"
" ..."
#:
../../faq/programming.rst:369
msgid
"but::"
msgstr
"sondern::"
#:
../../faq/programming.rst:371
msgid
""
"def foo(mydict=None):\n"
" if mydict is None:\n"
" mydict = {} # create a new dict for local namespace"
msgstr
""
"def foo(mydict=None):\n"
" if mydict is None:\n"
" mydict = {} # ein neues Dictionary für den lokalen Namensraum "
"erzeugen"
#:
../../faq/programming.rst:375
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
""
"Diese Eigenschaft kann nützlich sein. Wenn du eine Funktion hast, deren "
"Berechnung lange dauert, ist es eine gängige Technik, die Parameter und den "
"sich ergebenden Wert jedes Funktionsaufrufs zwischenzuspeichern und den "
"gespeicherten Wert zurückzugeben, falls derselbe Wert erneut angefordert "
"wird. Das nennt man „Memoisierung“ und lässt sich so umsetzen::"
#:
../../faq/programming.rst:380
msgid
""
"# Callers can only provide two parameters and optionally pass _cache by "
"keyword\n"
"def expensive(arg1, arg2, *, _cache={}):\n"
" if (arg1, arg2) in _cache:\n"
" return _cache[(arg1, arg2)]\n"
"\n"
" # Calculate the value\n"
" result = ... expensive computation ...\n"
" _cache[(arg1, arg2)] = result # Store result in the cache\n"
" return result"
msgstr
""
"# Aufrufer können nur zwei Parameter angeben und _cache wahlweise als "
"Schlüsselwort übergeben\n"
"def expensive(arg1, arg2, *, _cache={}):\n"
" if (arg1, arg2) in _cache:\n"
" return _cache[(arg1, arg2)]\n"
"\n"
" # den Wert berechnen\n"
" result = ... expensive computation ...\n"
" _cache[(arg1, arg2)] = result # Ergebnis im Zwischenspeicher "
"ablegen\n"
" return result"
#:
../../faq/programming.rst:390
msgid
""
"You could use a global variable containing a dictionary instead of the "
"default value; it's a matter of taste."
msgstr
""
"Du könntest statt des Vorgabewerts auch eine globale Variable mit einem "
"Dictionary verwenden. Das ist eine Frage des Geschmacks."
#:
../../faq/programming.rst:395
msgid
""
"How can I pass optional or keyword parameters from one function to another?"
msgstr
""
"Wie übergebe ich optionale Parameter oder Schlüsselwortparameter von einer "
"Funktion an eine andere?"
#:
../../faq/programming.rst:397
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
""
"Sammle die Argumente mit den Angaben ``*`` und ``**`` in der Parameterliste "
"der Funktion ein. Das gibt dir die Positionsargumente als Tupel und die "
"Schlüsselwortargumente als Dictionary. Diese Argumente kannst du dann beim "
"Aufruf einer anderen Funktion mit ``*`` und ``**`` weitergeben::"
#:
../../faq/programming.rst:402
msgid
""
"def f(x, *args, **kwargs):\n"
" ...\n"
" kwargs['width'] = '14.3c'\n"
" ...\n"
" g(x, *args, **kwargs)"
msgstr
""
"def f(x, *args, **kwargs):\n"
" ...\n"
" kwargs['width'] = '14.3c'\n"
" ...\n"
" g(x, *args, **kwargs)"
#:
../../faq/programming.rst:416
msgid
"What is the difference between arguments and parameters?"
msgstr
"Was ist der Unterschied zwischen Argumenten und Parametern?"
#:
../../faq/programming.rst:418
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 :term:"
"`kind of arguments <parameter>` a function can accept. For example, given "
"the function definition::"
msgstr
""
":term:`Parameter <parameter>` werden durch die Namen festgelegt, die in "
"einer Funktionsdefinition auftauchen, während :term:`Argumente <argument>` "
"die Werte sind, die beim Aufruf tatsächlich an eine Funktion übergeben "
"werden. Parameter legen fest, :term:`welche Art von Argumenten <parameter>` "
"eine Funktion annehmen kann. Betrachte zum Beispiel die folgende "
"Funktionsdefinition::"
#:
../../faq/programming.rst:424
msgid
""
"def func(foo, bar=None, **kwargs):\n"
" pass"
msgstr
""
"def func(foo, bar=None, **kwargs):\n"
" pass"
#:
../../faq/programming.rst:427
msgid
""
"*foo*, *bar* and *kwargs* are parameters of ``func``. However, when calling "
"``func``, for example::"
msgstr
""
"*foo*, *bar* und *kwargs* sind Parameter von ``func``. Beim Aufruf von "
"``func``, zum Beispiel::"
#:
../../faq/programming.rst:430
msgid
"func(42, bar=314, extra=somevar)"
msgstr
"func(42, bar=314, extra=somevar)"
#:
../../faq/programming.rst:432
msgid
"the values ``42``, ``314``, and ``somevar`` are arguments."
msgstr
"sind die Werte ``42``, ``314`` und ``somevar`` dagegen Argumente."
#:
../../faq/programming.rst:436
msgid
"Why did changing list 'y' also change list 'x'?"
msgstr
"Warum hat das Ändern von Liste 'y' auch Liste 'x' verändert?"
#:
../../faq/programming.rst:438
msgid
"If you wrote code like::"
msgstr
"Wenn du Code wie diesen geschrieben hast::"
#:
../../faq/programming.rst:440
msgid
""
">>> x = []\n"
">>> y = x\n"
">>> y.append(10)\n"
">>> y\n"
"[10]\n"
">>> x\n"
"[10]"
msgstr
""
">>> x = []\n"
">>> y = x\n"
">>> y.append(10)\n"
">>> y\n"
"[10]\n"
">>> x\n"
"[10]"
#:
../../faq/programming.rst:448
msgid
""
"you might be wondering why appending an element to ``y`` changed ``x`` too."
msgstr
""
"fragst du dich vielleicht, warum das Anhängen eines Elements an ``y`` auch "
"``x`` verändert hat."
#:
../../faq/programming.rst:450
msgid
"There are two factors that produce this result:"
msgstr
"Zwei Dinge führen zu diesem Ergebnis:"
#:
../../faq/programming.rst:452
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
""
"Variablen sind einfach Namen, die auf Objekte verweisen. ``y = x`` erzeugt "
"keine Kopie der Liste -- es erzeugt eine neue Variable ``y``, die auf "
"dasselbe Objekt verweist wie ``x``. Das bedeutet, dass es nur ein Objekt "
"gibt, nämlich die Liste, und dass ``x`` und ``y`` beide darauf verweisen."
#:
../../faq/programming.rst:456
msgid
""
"Lists are :term:`mutable`, which means that you can change their content."
msgstr
""
"Listen sind :term:`veränderlich <mutable>`, das heißt, du kannst ihren "
"Inhalt ändern."
#:
../../faq/programming.rst:458
msgid
""
"After the call to :meth:`~sequence.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
""
"Nach dem Aufruf von :meth:`~sequence.append` hat sich der Inhalt des "
"veränderlichen Objekts von ``[]`` zu ``[10]`` geändert. Da beide Variablen "
"auf dasselbe Objekt verweisen, greift man über jeden der beiden Namen auf "
"den geänderten Wert ``[10]`` zu."
#:
../../faq/programming.rst:462
msgid
"If we instead assign an immutable object to ``x``::"
msgstr
"Wenn wir ``x`` stattdessen ein unveränderliches Objekt zuweisen::"
#:
../../faq/programming.rst:464
msgid
""
">>> x = 5 # ints are immutable\n"
">>> y = x\n"
">>> x = x + 1 # 5 can't be mutated, we are creating a new object here\n"
">>> x\n"
"6\n"
">>> y\n"
"5"
msgstr
""
">>> x = 5 # ints sind unveränderlich\n"
">>> y = x\n"
">>> x = x + 1 # 5 lässt sich nicht verändern, hier wird ein neues Objekt "
"erzeugt\n"
">>> x\n"
"6\n"
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL