diff --git a/tutorial/datastructures.po b/tutorial/datastructures.po index e46d9b6..8cc22a1 100644 --- a/tutorial/datastructures.po +++ b/tutorial/datastructures.po @@ -21,40 +21,56 @@ msgstr "" "Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" + msgid "Data Structures" -msgstr "" +msgstr "Datenstrukturen" msgid "" "This chapter describes some things you've learned about already in more " "detail, and adds some new things as well." msgstr "" +"In diesem Kapitel werden einige Dinge, die Sie bereits kennengelernt haben, " +"näher erläutert, und es werden zudem einige neue Aspekte hinzugefügt." msgid "More on Lists" -msgstr "" +msgstr "Mehr zum Thema Listen" msgid "" -"The list data type has some more methods. Here are all of the methods of " -"list objects:" +"The :ref:`list ` data type has some more methods. Here are " +"all of the methods of list objects:" msgstr "" +"Der Datentyp :ref:`list ` verfügt über einige weitere " +"Methoden. Hier sind alle Methoden von Listenobjekten aufgeführt:" msgid "Add an item to the end of the list. Similar to ``a[len(a):] = [x]``." msgstr "" +"Füge einen Eintrag am Ende der Liste hinzu. Ähnlich wie bei ``a[len(a):] =" +" [x]`` msgid "" "Extend the list by appending all the items from the iterable. Similar to " "``a[len(a):] = iterable``." msgstr "" +"Erweitere die Liste, indem du alle Elemente aus der iterierbaren Struktur " +"anhängst. Ähnlich wie bei ``a[len(a):] = iterable`` ." msgid "" "Insert an item at a given position. The first argument is the index of the " "element before which to insert, so ``a.insert(0, x)`` inserts at the front " "of the list, and ``a.insert(len(a), x)`` is equivalent to ``a.append(x)``." msgstr "" +"Fügt ein Element an einer bestimmten Position ein. Das erste Argument ist " +"der Index des Elements, vor dem eingefügt werden soll. Daher fügt " +"``a.insert(0, x)`` am Anfang der Liste ein, und ``a.insert(len(a), x)`` " +"entspricht ``a.append(x)``." msgid "" -"Remove the first item from the list whose value is equal to *x*. It raises " -"a :exc:`ValueError` if there is no such item." +"Remove the first item from the list whose value is equal to *value*. It " +"raises a :exc:`ValueError` if there is no such item." msgstr "" +"Entferne das erste Element aus der Liste, dessen Wert *value* entspricht. " +"Wenn kein solches Element vorhanden ist, wird eine :exc:`ValueError`" +"ausgelöst." msgid "" "Remove the item at the given position in the list, and return it. If no " @@ -62,42 +78,60 @@ msgid "" "list. It raises an :exc:`IndexError` if the list is empty or the index is " "outside the list range." msgstr "" +"Entfernt das Element an der angegebenen Position aus der Liste und gibt es " +"zurück. Wenn kein Index angegeben wird, entfernt ``a.pop()``das letzte " +"Element der Liste und gibt es zurück. Es löst eine :exc:`IndexError`" +"aus, wenn die Liste leer ist oder der Index außerhalb des Listenbereichs " +"liegt." msgid "Remove all items from the list. Similar to ``del a[:]``." msgstr "" +"Entferne alle Elemente aus der Liste. Ähnlich wie bei ``del a[:]`` ." msgid "" -"Return zero-based index of the first occurrence of *x* in the list. Raises " -"a :exc:`ValueError` if there is no such item." +"Return zero-based index of the first occurrence of *value* in the list. " +"Raises a :exc:`ValueError` if there is no such item." msgstr "" +"Gibt den nullbasierten Index des ersten Vorkommens von *value* in der Liste " +"zurück. Löst eine Ausnahme vom Typ :exc:`ValueError`aus, wenn kein " +"entsprechendes Element vorhanden ist." msgid "" "The optional arguments *start* and *end* are interpreted as in the slice " -"notation and are used to limit the search to a particular subsequence of the " -"list. The returned index is computed relative to the beginning of the full " -"sequence rather than the *start* argument." +"notation and are used to limit the search to a particular subsequence of the" +" list. The returned index is computed relative to the beginning of the full" +" sequence rather than the *start* argument." msgstr "" +"Die optionalen Argumente *start* und *end* werden wie in der Slice-Notation " +"interpretiert und dienen dazu, die Suche auf eine bestimmte Teilfolge der " +"Liste zu beschränken. Der zurückgegebene Index wird relativ zum Anfang der " +"vollständigen Folge und nicht relativ zum Argument *start* berechnet." -msgid "Return the number of times *x* appears in the list." -msgstr "" +msgid "Return the number of times *value* appears in the list." +msgstr "Gibt die Anzahl der Vorkommen von *value* in der Liste zurück." msgid "" "Sort the items of the list in place (the arguments can be used for sort " "customization, see :func:`sorted` for their explanation)." msgstr "" +"Sortiere die Elemente der Liste an Ort und Stelle (die Argumente können zur " +"Anpassung der Sortierung verwendet werden; eine Erläuterung findest du unter" +" :func:`sorted` )." msgid "Reverse the elements of the list in place." msgstr "" +"Die Elemente der Liste an Ort und Stelle in umgekehrter Reihenfolge " +"anordnen." msgid "Return a shallow copy of the list. Similar to ``a[:]``." msgstr "" +"Gibt eine flache Kopie der Liste zurück. Ähnlich wie bei ``a[:]`` ." msgid "An example that uses most of the list methods::" -msgstr "" +msgstr "Ein Beispiel, das die meisten Methoden der Liste verwendet::" msgid "" -">>> fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', " -"'banana']\n" +">>> fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']\n" ">>> fruits.count('apple')\n" "2\n" ">>> fruits.count('tangerine')\n" @@ -118,6 +152,26 @@ msgid "" ">>> fruits.pop()\n" "'pear'" msgstr "" +">>> fruits = ['Orange', 'Apfel', 'Birne', 'Banane', 'Kiwi', 'Apfel', 'Banane']\n" +">>> fruits.count('Apfel')\n" +"2\n" +">>> fruits.count('Mandarine')\n" +"0\n" +">>> fruits.index('Banane')\n" +"3\n" +">>> fruits.index('banana', 4) # Die nächste Banane ab Position 4 finden\n" +"6\n" +">>> fruits.reverse()\n" +">>> fruits\n" +"['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange']\n" +">>> fruits.append('traube')\n" +">>> fruits\n" +"['banane', 'apfel', 'kiwi', 'banane', 'birne', 'apfel', 'orange', 'traube']\n" +">>> fruits.sort()\n" +">>> fruits\n" +"['Apfel', 'Apfel', 'Banane', 'Banane', 'Traube', 'Kiwi', 'Orange', 'Birne']\n" +">>> fruits.pop()\n" +"'Birne'" msgid "" "You might have noticed that methods like ``insert``, ``remove`` or ``sort`` " @@ -125,6 +179,11 @@ msgid "" "default ``None``. [#]_ This is a design principle for all mutable data " "structures in Python." msgstr "" +"Vielleicht ist Ihnen aufgefallen, dass bei Methoden wie ``insert`` “, " +"``remove``oder ``sort`` “, die lediglich die Liste verändern, kein " +"Rückgabewert ausgegeben wird – sie geben den Standardwert ``None``" +"zurück. [#]_ Dies ist ein Entwurfsprinzip für alle veränderbaren " +"Datenstrukturen in Python." msgid "" "Another thing you might notice is that not all data can be sorted or " @@ -133,17 +192,30 @@ msgid "" "other types. Also, there are some types that don't have a defined ordering " "relation. For example, ``3+4j < 5+7j`` isn't a valid comparison." msgstr "" +"Außerdem wird Ihnen vielleicht auffallen, dass nicht alle Daten sortiert " +"oder verglichen werden können. So lässt sich beispielsweise ``[None, " +"'hello', 10]``nicht sortieren, da Ganzzahlen nicht mit Zeichenketten " +"verglichen werden können und ``None``nicht mit anderen Typen verglichen" +" werden kann. Zudem gibt es einige Typen, für die keine definierte " +"Ordnungsrelation existiert. So ist beispielsweise ``3+4j < 5+7j``kein " +"gültiger Vergleich." msgid "Using Lists as Stacks" -msgstr "" +msgstr "Listen als Stapel verwenden" msgid "" "The list methods make it very easy to use a list as a stack, where the last " "element added is the first element retrieved (\"last-in, first-out\"). To " "add an item to the top of the stack, use :meth:`~list.append`. To retrieve " -"an item from the top of the stack, use :meth:`~list.pop` without an explicit " -"index. For example::" +"an item from the top of the stack, use :meth:`~list.pop` without an explicit" +" index. For example::" msgstr "" +"Die Listenmethoden machen es sehr einfach, eine Liste als Stapel zu " +"verwenden, bei dem das zuletzt hinzugefügte Element als erstes wieder " +"abgerufen wird (\"Last-in, First-out}“). Um ein Element oben auf den Stapel " +"zu setzen, verwenden Sie ` :meth:`~list.append``. Um ein Element von der " +"Spitze des Stapels abzurufen, verwenden Sie ` :meth:`~list.pop` ` ohne " +"expliziten Index. Beispiel::" msgid "" ">>> stack = [3, 4, 5]\n" @@ -162,22 +234,46 @@ msgid "" ">>> stack\n" "[3, 4]" msgstr "" +">>> stack = [3, 4, 5]\n" +">>> stack.append(6)\n" +">>> stack.append(7)\n" +">>> stack\n" +"[3, 4, 5, 6, 7]\n" +">>> stack.pop()\n" +"7\n" +">>> stack\n" +"[3, 4, 5, 6]\n" +">>> stack.pop()\n" +"6\n" +">>> stack.pop()\n" +"5\n" +">>> stack\n" +"[3, 4]" msgid "Using Lists as Queues" -msgstr "" +msgstr "Listen als Warteschlangen verwenden" msgid "" "It is also possible to use a list as a queue, where the first element added " -"is the first element retrieved (\"first-in, first-out\"); however, lists are " -"not efficient for this purpose. While appends and pops from the end of list " -"are fast, doing inserts or pops from the beginning of a list is slow " +"is the first element retrieved (\"first-in, first-out\"); however, lists are" +" not efficient for this purpose. While appends and pops from the end of " +"list are fast, doing inserts or pops from the beginning of a list is slow " "(because all of the other elements have to be shifted by one)." msgstr "" +"Es ist auch möglich, eine Liste als Warteschlange zu verwenden, bei der das " +"zuerst hinzugefügte Element als erstes wieder abgerufen wird (\"First-in, +"First-out\“); allerdings sind Listen für diesen Zweck nicht effizient. " +"Während das Anhängen und Entnehmen am Ende einer Liste schnell erfolgt, ist " +"das Einfügen oder Entnehmen am Anfang einer Liste langsam (da alle anderen " +"Elemente um eine Position verschoben werden müssen)." msgid "" "To implement a queue, use :class:`collections.deque` which was designed to " "have fast appends and pops from both ends. For example::" msgstr "" +"Um eine Warteschlange zu implementieren, verwenden Sie " +":class:`collections.deque` “, das für schnelles Hinzufügen und Entnehmen von" +" beiden Enden ausgelegt ist. Beispiel::" msgid "" ">>> from collections import deque\n" @@ -191,9 +287,19 @@ msgid "" ">>> queue # Remaining queue in order of arrival\n" "deque(['Michael', 'Terry', 'Graham'])" msgstr "" +">>> from collections import deque\n" +">>> queue = deque([\"Eric\", \"John\", \"Michael\"])\n" +">>> queue.append(\"Terry\") # Terry kommt an\n" +">>> queue.append(\"Graham\") # Graham kommt an\n" +">>> queue.popleft() # Der Erste, der angekommen ist, verlässt nun die Warteschlange\n" +"'Eric'\n" +">>> queue.popleft() # Der Zweite, der angekommen ist, verlässt nun die Warteschlange\n" +"'John'\n" +">>> queue # Verbleibende Warteschlange in der Reihenfolge der Ankunft\n" +"deque(['Michael', 'Terry', 'Graham'])" msgid "List Comprehensions" -msgstr "" +msgstr "Listen-Abstraktion" msgid "" "List comprehensions provide a concise way to create lists. Common " @@ -201,9 +307,17 @@ msgid "" "operations applied to each member of another sequence or iterable, or to " "create a subsequence of those elements that satisfy a certain condition." msgstr "" +"Listen-Abstraktion bieten eine prägnante Möglichkeit, Listen zu erstellen. " +"Häufige Anwendungsfälle sind die Erstellung neuer Listen, bei denen jedes " +"Element das Ergebnis bestimmter Operationen ist, die auf jedes Element einer" +" anderen Sequenz oder eines anderen iterierbaren Objekts angewendet werden, " +"oder die Erstellung einer Teilsequenz aus den Elementen, die eine bestimmte " +"Bedingung erfüllen." msgid "For example, assume we want to create a list of squares, like::" msgstr "" +"Nehmen wir zum Beispiel an, wir möchten eine Liste von Quadraten erstellen, " +"etwa wie folgt:" msgid "" ">>> squares = []\n" @@ -213,41 +327,60 @@ msgid "" ">>> squares\n" "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" msgstr "" +">>> squares = []\n" +">>> for x in range(10):\n" +"... squares.append(x**2)\n" +"...\n" +">>> squares\n" +"[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]" msgid "" "Note that this creates (or overwrites) a variable named ``x`` that still " "exists after the loop completes. We can calculate the list of squares " "without any side effects using::" msgstr "" +"Beachten Sie, dass dadurch eine Variable namens ``x``angelegt (oder " +"überschrieben) wird, die auch nach Abschluss der Schleife noch vorhanden " +"ist. Wir können die Liste der Quadrate ohne Nebenwirkungen wie folgt " +"berechnen:" msgid "squares = list(map(lambda x: x**2, range(10)))" -msgstr "" +msgstr "Quadrate = list(map(lambda x: x**2, range(10)))" msgid "or, equivalently::" -msgstr "" +msgstr "oder, gleichbedeutend::" msgid "squares = [x**2 for x in range(10)]" -msgstr "" +msgstr "Quadrate = [x**2 for x in range(10)]" msgid "which is more concise and readable." -msgstr "" +msgstr "was prägnanter und besser lesbar ist." msgid "" "A list comprehension consists of brackets containing an expression followed " -"by a :keyword:`!for` clause, then zero or more :keyword:`!for` or :keyword:`!" -"if` clauses. The result will be a new list resulting from evaluating the " -"expression in the context of the :keyword:`!for` and :keyword:`!if` clauses " -"which follow it. For example, this listcomp combines the elements of two " -"lists if they are not equal::" +"by a :keyword:`!for` clause, then zero or more :keyword:`!for` or " +":keyword:`!if` clauses. The result will be a new list resulting from " +"evaluating the expression in the context of the :keyword:`!for` and " +":keyword:`!if` clauses which follow it. For example, this listcomp combines " +"the elements of two lists if they are not equal::" msgstr "" +"Eine Listenkomprimierung besteht aus Klammern, die einen Ausdruck enthalten," +" gefolgt von einer :keyword:`!for` “-Klausel und anschließend null oder " +"mehr :keyword:`!for` “- oder :keyword:`!if` “-Klauseln. Das Ergebnis ist" +" eine neue Liste, die sich aus der Auswertung des Ausdrucks im Kontext der " +"darauf folgenden :keyword:`!for` “- und :keyword:`!if` “-Klauseln " +"ergibt. Diese Listenkomprimierung kombiniert beispielsweise die Elemente " +"zweier Listen, sofern sie nicht identisch sind:" msgid "" ">>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]\n" "[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" msgstr "" +">>> [(x, y) für x in [1, 2, 3] für y in [3, 1, 4], wenn x != y]\n" +"[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" msgid "and it's equivalent to::" -msgstr "" +msgstr "und das entspricht::" msgid "" ">>> combs = []\n" @@ -259,16 +392,28 @@ msgid "" ">>> combs\n" "[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" msgstr "" +">>> combs = []\n" +">>> for x in [1, 2, 3]:\n" +"... for y in [3, 1, 4]:\n" +"... if x != y:\n" +"... combs.append((x, y))\n" +"...\n" +">>> combs\n" +"[(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]" msgid "" -"Note how the order of the :keyword:`for` and :keyword:`if` statements is the " -"same in both these snippets." +"Note how the order of the :keyword:`for` and :keyword:`if` statements is the" +" same in both these snippets." msgstr "" +"Beachten Sie, dass die Reihenfolge der Anweisungen :keyword:`for`und " +":keyword:`if`in beiden Codeausschnitten identisch ist." msgid "" "If the expression is a tuple (e.g. the ``(x, y)`` in the previous example), " "it must be parenthesized. ::" msgstr "" +"Wenn es sich bei dem Ausdruck um ein Tupel handelt (z. B. ``(x, y)``im " +"vorherigen Beispiel), muss es in Klammern gesetzt werden. ::" msgid "" ">>> vec = [-4, -2, 0, 2, 4]\n" @@ -299,29 +444,65 @@ msgid "" ">>> [num for elem in vec for num in elem]\n" "[1, 2, 3, 4, 5, 6, 7, 8, 9]" msgstr "" +">>> vec = [-4, -2, 0, 2, 4]\n" +">>> # Erstelle eine neue Liste, in der die Werte verdoppelt sind\n" +">>> [x*2 for x in vec]\n" +"[-8, -4, 0, 4, 8]\n" +">>> # Filtere die Liste, um negative Zahlen auszuschließen\n" +">>> [x for x in vec if x >= 0]\n" +"[0, 2, 4]\n" +">>> # Eine Funktion auf alle Elemente anwenden\n" +">>> [abs(x) for x in vec]\n" +"[4, 2, 0, 2, 4]\n" +">>> # Eine Methode auf jedes Element anwenden\n" +">>> freshfruit = [' banana', ' loganberry ', 'passion fruit ']\n" +">>> [weapon.strip() for weapon in freshfruit]\n" +"['banana', 'loganberry', 'passion fruit']\n" +">>> # Eine Liste von 2-Tupeln wie (Zahl, Quadrat) erstellen\n" +">>> [(x, x**2) for x in range(6)]\n" +"[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]\n" +">>> # Das Tupel muss in Klammern gesetzt werden, sonst wird ein Fehler ausgelöst\n" +">>> [x, x**2 for x in range(6)]\n" +" Datei \"\", Zeile 1\n" +" [x, x**2 for x in range(6)]\n" +" ^^^^^^^\n" +"SyntaxError: Hast du die Klammern um das Ziel der List Comprehension vergessen?\n" +">>> # Eine Liste mithilfe einer List Comprehension mit zwei \"for\“-Schleifen abflachen\n" +">>> vec = [[1,2,3], [4,5,6], [7,8,9]]\n" +">>> [num for elem in vec for num in elem]\n" +"[1, 2, 3, 4, 5, 6, 7, 8, 9]" msgid "" "List comprehensions can contain complex expressions and nested functions::" msgstr "" +"Listen-Abstraktionen können komplexe Ausdrücke und verschachtelte Funktionen" +" enthalten::" msgid "" ">>> from math import pi\n" ">>> [str(round(pi, i)) for i in range(1, 6)]\n" "['3.1', '3.14', '3.142', '3.1416', '3.14159']" msgstr "" +">>> from math import pi\n" +">>> [str(round(pi, i)) for i in range(1, 6)]\n" +"['3,1', '3,14', '3,142', '3,1416', '3,14159']" msgid "Nested List Comprehensions" -msgstr "" +msgstr "Verschachtelte Listen-Abstraktion" msgid "" "The initial expression in a list comprehension can be any arbitrary " "expression, including another list comprehension." msgstr "" +"Der erste Ausdruck in einer Listen-Abstraktion kann ein beliebiger Ausdruck " +"sein, einschließlich einer weiteren Listen-Abstraktion." msgid "" "Consider the following example of a 3x4 matrix implemented as a list of 3 " "lists of length 4::" msgstr "" +"Betrachte das folgende Beispiel einer 3×4-Matrix, die als Liste aus drei " +"Listen der Länge 4 implementiert ist::" msgid "" ">>> matrix = [\n" @@ -330,20 +511,30 @@ msgid "" "... [9, 10, 11, 12],\n" "... ]" msgstr "" +">>> matrix = [\n" +"... [1, 2, 3, 4],\n" +"... [5, 6, 7, 8],\n" +"... [9, 10, 11, 12],\n" +"... ]" msgid "The following list comprehension will transpose rows and columns::" -msgstr "" +msgstr "Die folgende Listen-Abstraktion transponiert Zeilen und Spalten::" msgid "" ">>> [[row[i] for row in matrix] for i in range(4)]\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgstr "" +">>> [[row[i] for row in matrix] for i in range(4)]\n" +"[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgid "" -"As we saw in the previous section, the inner list comprehension is evaluated " -"in the context of the :keyword:`for` that follows it, so this example is " +"As we saw in the previous section, the inner list comprehension is evaluated" +" in the context of the :keyword:`for` that follows it, so this example is " "equivalent to::" msgstr "" +"Wie wir im vorigen Abschnitt gesehen haben, wird die innere Listenauswertung" +" im Kontext des darauf folgenden :keyword:`for`ausgewertet, sodass " +"dieses Beispiel gleichbedeutend ist mit::" msgid "" ">>> transposed = []\n" @@ -353,9 +544,15 @@ msgid "" ">>> transposed\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgstr "" +">>> transposed = []\n" +">>> for i in range(4):\n" +"... transposed.append([row[i] for row in matrix])\n" +"...\n" +">>> transposed\n" +"[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgid "which, in turn, is the same as::" -msgstr "" +msgstr "was wiederum dasselbe ist wie::" msgid "" ">>> transposed = []\n" @@ -369,31 +566,57 @@ msgid "" ">>> transposed\n" "[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgstr "" +">>> transposed = []\n" +">>> for i in range(4):\n" +"... # Die folgenden 3 Zeilen implementieren die verschachtelte Listenkomposition\n" +"... transposed_row = []\n" +"... for row in matrix:\n" +"... transposed_row.append(row[i])\n" +"... transponiert.append(transponierte_Zeile)\n" +"...\n" +">>> transponiert\n" +"[[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]" msgid "" "In the real world, you should prefer built-in functions to complex flow " -"statements. The :func:`zip` function would do a great job for this use case::" +"statements. The :func:`zip` function would do a great job for this use " +"case::" msgstr "" +"In der Praxis sollten Sie integrierte Funktionen komplexen Ablaufanweisungen" +" vorziehen. Die Funktion :func:`zip`eignet sich hervorragend für diesen" +" Anwendungsfall:" msgid "" ">>> list(zip(*matrix))\n" "[(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]" msgstr "" +">>> list(zip(*matrix))\n" +"[(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]" msgid "" "See :ref:`tut-unpacking-arguments` for details on the asterisk in this line." msgstr "" +"Weitere Informationen zum Sternchen in dieser Zeile finden Sie unter " +":ref:`tut-unpacking-arguments`." msgid "The :keyword:`!del` statement" -msgstr "" +msgstr "Die Erklärung der :keyword:`!del` “" msgid "" "There is a way to remove an item from a list given its index instead of its " -"value: the :keyword:`del` statement. This differs from the :meth:`~list." -"pop` method which returns a value. The :keyword:`!del` statement can also " -"be used to remove slices from a list or clear the entire list (which we did " -"earlier by assignment of an empty list to the slice). For example::" +"value: the :keyword:`del` statement. This differs from the " +":meth:`~list.pop` method which returns a value. The :keyword:`!del` " +"statement can also be used to remove slices from a list or clear the entire " +"list (which we did earlier by assignment of an empty list to the slice). " +"For example::" msgstr "" +"Es gibt eine Möglichkeit, ein Element anhand seines Indexes statt seines " +"Wertes aus einer Liste zu entfernen: die Anweisung :keyword:`del` “. Diese" +" unterscheidet sich von der Methode :meth:`~list.pop` “, die einen Wert " +"zurückgibt. Die Anweisung :keyword:`!del`kann auch verwendet werden, um" +" Teilmengen aus einer Liste zu entfernen oder die gesamte Liste zu leeren " +"(was wir zuvor durch die Zuweisung einer leeren Liste zur Teilmenge getan " +"haben). Zum Beispiel::" msgid "" ">>> a = [-1, 1, 66.25, 333, 333, 1234.5]\n" @@ -407,32 +630,54 @@ msgid "" ">>> a\n" "[]" msgstr "" +">>> a = [-1, 1, 66,25, 333, 333, 1234,5]\n" +">>> del a[0]\n" +">>> a\n" +"[1, 66,25, 333, 333, 1234,5]\n" +">>> del a[2:4]\n" +">>> a\n" +"[1, 66,25, 1234,5]\n" +">>> del a[:]\n" +">>> a\n" +"[]" msgid ":keyword:`del` can also be used to delete entire variables::" msgstr "" +":keyword:`del` kann auch zum Löschen ganzer Variablen verwendet werden::" msgid ">>> del a" -msgstr "" +msgstr ">>> del a" msgid "" "Referencing the name ``a`` hereafter is an error (at least until another " "value is assigned to it). We'll find other uses for :keyword:`del` later." msgstr "" +"Der Verweis auf den Namen ``a``ist hier ein Fehler (zumindest solange, " +"bis ihm ein anderer Wert zugewiesen wird). Wir werden später noch weitere " +"Verwendungsmöglichkeiten für :keyword:`del`finden." msgid "Tuples and Sequences" -msgstr "" +msgstr "Tupel und Sequenzen" msgid "" "We saw that lists and strings have many common properties, such as indexing " -"and slicing operations. They are two examples of *sequence* data types " -"(see :ref:`typesseq`). Since Python is an evolving language, other sequence " -"data types may be added. There is also another standard sequence data type: " -"the *tuple*." +"and slicing operations. They are two examples of *sequence* data types (see" +" :ref:`typesseq`). Since Python is an evolving language, other sequence " +"data types may be added. There is also another standard sequence data type:" +" the *tuple*." msgstr "" +"Wir haben gesehen, dass Listen und Zeichenketten viele gemeinsame " +"Eigenschaften haben, wie beispielsweise Indizierungs- und " +"Ausschnittoperationen. Sie sind zwei Beispiele für *Sequenz*-Datentypen " +"(siehe :ref:`typesseq`). Da Python eine sich weiterentwickelnde Sprache ist," +" können weitere Sequenz-Datentypen hinzukommen. Es gibt außerdem einen " +"weiteren standardmäßigen Sequenz-Datentyp: das *Tupel*." msgid "" "A tuple consists of a number of values separated by commas, for instance::" msgstr "" +"Ein Tupel besteht aus einer Reihe von Werten, die durch Kommas getrennt " +"sind, zum Beispiel::" msgid "" ">>> t = 12345, 54321, 'hello!'\n" @@ -454,33 +699,72 @@ msgid "" ">>> v\n" "([1, 2, 3], [3, 2, 1])" msgstr "" +">>> t = 12345, 54321, 'hello!'\n" +">>> t[0]\n" +"12345\n" +">>> t\n" +"(12345, 54321, 'hello!')\n" +">>> # Tupel können verschachtelt sein:\n" +">>> u = t, (1, 2, 3, 4, 5)\n" +">>> u\n" +"((12345, 54321, 'hello!'), (1, 2, 3, 4, 5))\n" +">>> # Tupel sind unveränderlich:\n" +">>> t[0] = 88888\n" +"Traceback (letzter Aufruf zuletzt):\n" +" Datei \"\, Zeile 1, in \n" +"TypeError: Das Objekt \"tuple\“ unterstützt keine Elementzuweisung\n" +">>> # können jedoch veränderbare Objekte enthalten:\n" +">>> v = ([1, 2, 3], [3, 2, 1])\n" +">>> v\n" +"([1, 2, 3], [3, 2, 1])" msgid "" "As you see, on output tuples are always enclosed in parentheses, so that " "nested tuples are interpreted correctly; they may be input with or without " -"surrounding parentheses, although often parentheses are necessary anyway (if " -"the tuple is part of a larger expression). It is not possible to assign to " -"the individual items of a tuple, however it is possible to create tuples " +"surrounding parentheses, although often parentheses are necessary anyway (if" +" the tuple is part of a larger expression). It is not possible to assign to" +" the individual items of a tuple, however it is possible to create tuples " "which contain mutable objects, such as lists." msgstr "" +"Wie Sie sehen, werden Tupel in der Ausgabe immer in Klammern gesetzt, damit " +"verschachtelte Tupel korrekt interpretiert werden; sie können mit oder ohne " +"umschließende Klammern eingegeben werden, obwohl Klammern oft ohnehin " +"erforderlich sind (wenn das Tupel Teil eines größeren Ausdrucks ist). Es " +"ist nicht möglich, den einzelnen Elementen eines Tupels Werte zuzuweisen; es" +" ist jedoch möglich, Tupel zu erstellen, die veränderbare Objekte wie " +"beispielsweise Listen enthalten." msgid "" "Though tuples may seem similar to lists, they are often used in different " "situations and for different purposes. Tuples are :term:`immutable`, and " "usually contain a heterogeneous sequence of elements that are accessed via " "unpacking (see later in this section) or indexing (or even by attribute in " -"the case of :func:`namedtuples `). Lists are :term:" -"`mutable`, and their elements are usually homogeneous and are accessed by " -"iterating over the list." -msgstr "" - -msgid "" -"A special problem is the construction of tuples containing 0 or 1 items: the " -"syntax has some extra quirks to accommodate these. Empty tuples are " +"the case of :func:`namedtuples `). Lists are " +":term:`mutable`, and their elements are usually homogeneous and are accessed" +" by iterating over the list." +msgstr "" +"Auch wenn Tupel auf den ersten Blick Listen ähneln mögen, werden sie oft in " +"anderen Situationen und für andere Zwecke verwendet. Tupel sind " +":term:`unveränderlich` und enthalten in der Regel eine heterogene Folge von " +"Elementen, auf die über Entpacken (siehe weiter unten in diesem Abschnitt) " +"oder Indizierung (oder im Fall von :func:`namedtuples " +"` sogar über Attribute) zugegriffen wird. Listen " +"sind :term:`veränderlich`, und ihre Elemente sind in der Regel homogen; der " +"Zugriff erfolgt durch Iteration über die Liste." + +msgid "" +"A special problem is the construction of tuples containing 0 or 1 items: the" +" syntax has some extra quirks to accommodate these. Empty tuples are " "constructed by an empty pair of parentheses; a tuple with one item is " "constructed by following a value with a comma (it is not sufficient to " "enclose a single value in parentheses). Ugly, but effective. For example::" msgstr "" +"Ein besonderes Problem stellt die Bildung von Tupeln dar, die 0 oder 1 " +"Element enthalten: Die Syntax weist hierfür einige zusätzliche " +"Besonderheiten auf. Leere Tupel werden durch ein leeres Klammerpaar " +"gebildet; ein Tupel mit einem Element wird gebildet, indem man einem Wert " +"ein Komma nachsetzt (es reicht nicht aus, einen einzelnen Wert in Klammern " +"zu setzen). Unschön, aber effektiv. Zum Beispiel::" msgid "" ">>> empty = ()\n" @@ -492,34 +776,58 @@ msgid "" ">>> singleton\n" "('hello',)" msgstr "" +">>> empty = ()\n" +">>> singleton = 'hello', # <-- note trailing comma\n" +">>> len(empty)\n" +"0\n" +">>> len(singleton)\n" +"1\n" +">>> singleton\n" +"('hello',)" msgid "" "The statement ``t = 12345, 54321, 'hello!'`` is an example of *tuple " "packing*: the values ``12345``, ``54321`` and ``'hello!'`` are packed " "together in a tuple. The reverse operation is also possible::" msgstr "" +"Die Anweisung ``t = 12345, 54321, 'hello!'``ist ein Beispiel für " +"*Tupel-Packing*: Die Werte ``12345`` “, ``54321``und ``'hello!'`` “" +" werden in einem Tupel zusammengefasst. Auch die umgekehrte Operation ist " +"möglich::" msgid ">>> x, y, z = t" -msgstr "" +msgstr ">>> x, y, z = t" msgid "" -"This is called, appropriately enough, *sequence unpacking* and works for any " -"sequence on the right-hand side. Sequence unpacking requires that there are " -"as many variables on the left side of the equals sign as there are elements " -"in the sequence. Note that multiple assignment is really just a combination " -"of tuple packing and sequence unpacking." +"This is called, appropriately enough, *sequence unpacking* and works for any" +" sequence on the right-hand side. Sequence unpacking requires that there " +"are as many variables on the left side of the equals sign as there are " +"elements in the sequence. Note that multiple assignment is really just a " +"combination of tuple packing and sequence unpacking." msgstr "" +"Dies wird passenderweise als *Sequenz-Entpackung* bezeichnet und " +"funktioniert für jede beliebige Sequenz auf der rechten Seite. Für die " +"Sequenz-Entpackung muss die Anzahl der Variablen auf der linken Seite des " +"Gleichheitszeichens der Anzahl der Elemente in der Sequenz entsprechen. " +"Beachten Sie, dass die Mehrfachzuweisung im Grunde nur eine Kombination aus " +"Tupel-Packing und Sequenz-Unpacking ist." msgid "Sets" -msgstr "" +msgstr "Sets" msgid "" -"Python also includes a data type for *sets*. A set is an unordered " -"collection with no duplicate elements. Basic uses include membership " -"testing and eliminating duplicate entries. Set objects also support " -"mathematical operations like union, intersection, difference, and symmetric " -"difference." +"Python also includes a data type for :ref:`sets `. A set is an " +"unordered collection with no duplicate elements. Basic uses include " +"membership testing and eliminating duplicate entries. Set objects also " +"support mathematical operations like union, intersection, difference, and " +"symmetric difference." msgstr "" +"Python enthält außerdem einen Datentyp für :ref:`Mengen `. Eine " +"Menge ist eine ungeordnete Sammlung ohne doppelte Elemente. Zu den " +"grundlegenden Anwendungsbereichen gehören die Überprüfung der Zugehörigkeit " +"zu einer Menge und das Entfernen doppelter Einträge. Mengenobjekte " +"unterstützen zudem mathematische Operationen wie Vereinigung, Schnittmenge, " +"Differenz und symmetrische Differenz." msgid "" "Curly braces or the :func:`set` function can be used to create sets. Note: " @@ -527,14 +835,26 @@ msgid "" "creates an empty dictionary, a data structure that we discuss in the next " "section." msgstr "" +"Zum Erstellen von Mengen können geschweifte Klammern oder die Funktion " +":func:`set`verwendet werden. Hinweis: Um eine leere Menge zu erstellen, " +"müssen Sie ``set()``verwenden, nicht ``{}`` “; Letzteres erstellt ein" +" leeres Wörterbuch, eine Datenstruktur, die wir im nächsten Abschnitt " +"behandeln." -msgid "Here is a brief demonstration::" +msgid "" +"Because sets are unordered, iterating over them or printing them can produce" +" the elements in a different order than you expect." msgstr "" +"Da Mengen ungeordnet sind, kann es beim Durchlaufen oder Ausgeben der " +"Elemente vorkommen, dass diese in einer anderen Reihenfolge angezeigt " +"werden, als Sie erwarten." + +msgid "Here is a brief demonstration::" +msgstr "Hier eine kurze Demonstration:" msgid "" ">>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}\n" -">>> print(basket) # show that duplicates have been " -"removed\n" +">>> print(basket) # show that duplicates have been removed\n" "{'orange', 'banana', 'pear', 'apple'}\n" ">>> 'orange' in basket # fast membership testing\n" "True\n" @@ -556,56 +876,114 @@ msgid "" ">>> a ^ b # letters in a or b but not both\n" "{'r', 'd', 'b', 'm', 'z', 'l'}" msgstr "" +">>> basket = {'Apfel', 'Orange', 'Apfel', 'Birne', 'Orange', 'Banane'}\n" +">>> print(basket) # zeigt, dass Duplikate entfernt wurden\n" +"{'Orange', 'Banane', 'Birne', 'Apfel'}\n" +">>> 'orange' in basket # schnelle Zugehörigkeitsprüfung\n" +"True\n" +">>> 'crabgrass' in basket\n" +"False\n" +"\n" +">>> # Demonstration von Mengenoperationen mit eindeutigen Buchstaben aus zwei Wörtern\n" +">>>\n" +">>> a = set('abracadabra')\n" +">>> b = set('alacazam')\n" +">>> a # eindeutige Buchstaben in a\n" +"{'a', 'r', 'b', 'c', 'd'}\n" +">>> a - b # Buchstaben in a, die nicht in b vorkommen\n" +"{'r', 'd', 'b'}\n" +">>> a | b # Buchstaben in a oder b oder in beiden\n" +"{'a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'}\n" +">>> a & b # Buchstaben, die sowohl in a als auch in b vorkommen\n" +"{'a', 'c'}\n" +">>> a ^ b # Buchstaben, die entweder in a oder in b vorkommen, aber nicht in beiden\n" +"{'r', 'd', 'b', 'm', 'z', 'l'}" msgid "" "Similarly to :ref:`list comprehensions `, set comprehensions " "are also supported::" msgstr "" +"Ähnlich wie bei den :ref:`Listenkomprimierungen ` werden auch" +" Mengekomprimierungen unterstützt::" msgid "" ">>> a = {x for x in 'abracadabra' if x not in 'abc'}\n" ">>> a\n" "{'r', 'd'}" msgstr "" +">>> a = {x for x in 'abracadabra' if x not in 'abc'}\n" +">>> a\n" +"{'r', 'd'}" msgid "Dictionaries" -msgstr "" - -msgid "" -"Another useful data type built into Python is the *dictionary* (see :ref:" -"`typesmapping`). Dictionaries are sometimes found in other languages as " -"\"associative memories\" or \"associative arrays\". Unlike sequences, which " -"are indexed by a range of numbers, dictionaries are indexed by *keys*, which " -"can be any immutable type; strings and numbers can always be keys. Tuples " -"can be used as keys if they contain only strings, numbers, or tuples; if a " -"tuple contains any mutable object either directly or indirectly, it cannot " -"be used as a key. You can't use lists as keys, since lists can be modified " -"in place using index assignments, slice assignments, or methods like :meth:" -"`~list.append` and :meth:`~list.extend`." -msgstr "" - -msgid "" -"It is best to think of a dictionary as a set of *key: value* pairs, with the " -"requirement that the keys are unique (within one dictionary). A pair of " +msgstr "Wörterbücher" + +msgid "" +"Another useful data type built into Python is the *dictionary* (see " +":ref:`typesmapping`). Dictionaries are sometimes found in other languages as" +" \"associative memories\" or \"associative arrays\". Unlike sequences, " +"which are indexed by a range of numbers, dictionaries are indexed by *keys*," +" which can be any immutable type; strings and numbers can always be keys. " +"Tuples can be used as keys if they contain only strings, numbers, or tuples;" +" if a tuple contains any mutable object either directly or indirectly, it " +"cannot be used as a key. You can't use lists as keys, since lists can be " +"modified in place using index assignments, slice assignments, or methods " +"like :meth:`~list.append` and :meth:`~list.extend`." +msgstr "" +"Ein weiterer nützlicher, in Python integrierter Datentyp ist das " +"*Wörterbuch* (siehe :ref:`typesmapping`). Wörterbücher werden in anderen " +"Sprachen manchmal als \"assoziative Speicher\“ oder \"assoziative Arrays\“ " +"bezeichnet. Im Gegensatz zu Sequenzen, die durch einen Zahlenbereich " +"indiziert werden, werden Dictionaries durch *Schlüssel* indiziert, die von " +"jedem unveränderlichen Typ sein können; Zeichenketten und Zahlen können " +"immer als Schlüssel verwendet werden. Tupel können als Schlüssel verwendet " +"werden, wenn sie ausschließlich Zeichenketten, Zahlen oder Tupel enthalten; " +"enthält ein Tupel direkt oder indirekt ein veränderbliches Objekt, kann es " +"nicht als Schlüssel verwendet werden. Listen können nicht als Schlüssel " +"verwendet werden, da sie durch Indexzuweisungen, Slice-Zuweisungen oder " +"Methoden wie ` :meth:`~list.append` ` und ` :meth:`~list.extend`` an Ort und" +" Stelle verändert werden können." + +msgid "" +"It is best to think of a dictionary as a set of *key: value* pairs, with the" +" requirement that the keys are unique (within one dictionary). A pair of " "braces creates an empty dictionary: ``{}``. Placing a comma-separated list " "of key:value pairs within the braces adds initial key:value pairs to the " "dictionary; this is also the way dictionaries are written on output." msgstr "" +"Man kann sich ein Wörterbuch am besten als eine Menge von " +"*Schlüssel:Wert*-Paaren vorstellen, wobei die Schlüssel (innerhalb eines " +"Wörterbuchs) eindeutig sein müssen. Ein Paar geschweifter Klammern erstellt " +"ein leeres Wörterbuch: ``{}``. Durch Einfügen einer durch Kommas getrennten " +"Liste von Schlüssel:Wert-Paaren innerhalb der geschweiften Klammern werden " +"dem Wörterbuch anfängliche Schlüssel:Wert-Paare hinzugefügt; auf diese Weise" +" werden Wörterbücher auch bei der Ausgabe dargestellt." msgid "" "The main operations on a dictionary are storing a value with some key and " -"extracting the value given the key. It is also possible to delete a key:" -"value pair with ``del``. If you store using a key that is already in use, " -"the old value associated with that key is forgotten." +"extracting the value given the key. It is also possible to delete a " +"key:value pair with ``del``. If you store using a key that is already in " +"use, the old value associated with that key is forgotten." msgstr "" +"Die wichtigsten Operationen in einem Wörterbuch sind das Speichern eines " +"Werts unter einem bestimmten Schlüssel und das Abrufen des Werts anhand des " +"Schlüssels. Es ist außerdem möglich, ein Schlüssel-Wert-Paar mit ` ``del``` " +"zu löschen. Wenn Sie einen Wert unter einem Schlüssel speichern, der bereits" +" verwendet wird, wird der alte, diesem Schlüssel zugeordnete Wert verworfen." msgid "" "Extracting a value for a non-existent key by subscripting (``d[key]``) " "raises a :exc:`KeyError`. To avoid getting this error when trying to access " -"a possibly non-existent key, use the :meth:`~dict.get` method instead, which " -"returns ``None`` (or a specified default value) if the key is not in the " +"a possibly non-existent key, use the :meth:`~dict.get` method instead, which" +" returns ``None`` (or a specified default value) if the key is not in the " "dictionary." msgstr "" +"Der Versuch, einen Wert für einen nicht vorhandenen Schlüssel mittels " +"Indexierung abzurufen (``d[key]``), löst einen :exc:`KeyError`aus. Um " +"diesen Fehler beim Zugriff auf einen möglicherweise nicht vorhandenen " +"Schlüssel zu vermeiden, verwenden Sie stattdessen die Methode " +":meth:`~dict.get` “, die ``None``(oder einen angegebenen Standardwert) " +"zurückgibt, wenn der Schlüssel nicht im Wörterbuch enthalten ist." msgid "" "Performing ``list(d)`` on a dictionary returns a list of all the keys used " @@ -613,9 +991,16 @@ msgid "" "``sorted(d)`` instead). To check whether a single key is in the dictionary, " "use the :keyword:`in` keyword." msgstr "" +"Wendet man ``list(d)``auf ein Wörterbuch an, wird eine Liste aller im " +"Wörterbuch verwendeten Schlüssel in der Reihenfolge ihrer Einfügung " +"zurückgegeben (wenn Sie die Liste sortiert haben möchten, verwenden Sie " +"stattdessen einfach ``sorted(d)`` “). Um zu prüfen, ob ein einzelner " +"Schlüssel im Wörterbuch enthalten ist, verwenden Sie das Schlüsselwort " +":keyword:`in` ." msgid "Here is a small example using a dictionary::" msgstr "" +"Hier ist ein kleines Beispiel, bei dem ein Wörterbuch verwendet wird::" msgid "" ">>> tel = {'jack': 4098, 'sape': 4139}\n" @@ -643,44 +1028,83 @@ msgid "" ">>> 'jack' not in tel\n" "False" msgstr "" +">>> tel = {'jack': 4098, 'sape': 4139}\n" +">>> tel['guido'] = 4127\n" +">>> tel\n" +"{'jack': 4098, 'sape': 4139, 'guido': 4127}\n" +">>> tel['jack']\n" +"4098\n" +">>> tel['irv']\n" +"Traceback (letzter Aufruf zuletzt):\n" +" Datei \"\", Zeile 1, in \n" +"KeyError: 'irv'\n" +">>> print(tel.get('irv'))\n" +"None\n" +">>> del tel['sape']\n" +">>> tel['irv'] = 4127\n" +">>> tel\n" +"{'jack': 4098, 'guido': 4127, 'irv': 4127}\n" +">>> list(tel)\n" +"['jack', 'guido', 'irv']\n" +">>> sorted(tel)\n" +"['guido', 'irv', 'jack']\n" +">>> 'guido' in tel\n" +"True\n" +">>> 'jack' not in tel\n" +"False" msgid "" "The :func:`dict` constructor builds dictionaries directly from sequences of " "key-value pairs::" msgstr "" +"Der Konstruktor ` :func:`dict` ` erstellt Wörterbücher direkt aus Sequenzen " +"von Schlüssel-Wert-Paaren::" msgid "" ">>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" msgstr "" +">>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])\n" +"{'sape': 4139, 'guido': 4127, 'jack': 4098}" msgid "" "In addition, dict comprehensions can be used to create dictionaries from " "arbitrary key and value expressions::" msgstr "" +"Darüber hinaus können Dict-Comprehensions verwendet werden, um Wörterbücher " +"aus beliebigen Schlüssel- und Wert-Ausdrücken zu erstellen::" msgid "" ">>> {x: x**2 for x in (2, 4, 6)}\n" "{2: 4, 4: 16, 6: 36}" msgstr "" +">>> {x: x**2 for x in (2, 4, 6)}\n" +"{2: 4, 4: 16, 6: 36}" msgid "" "When the keys are simple strings, it is sometimes easier to specify pairs " "using keyword arguments::" msgstr "" +"Wenn es sich bei den Schlüsseln um einfache Zeichenfolgen handelt, ist es " +"manchmal einfacher, Paare mithilfe von Schlüsselwortargumenten anzugeben::" msgid "" ">>> dict(sape=4139, guido=4127, jack=4098)\n" "{'sape': 4139, 'guido': 4127, 'jack': 4098}" msgstr "" +">>> dict(sape=4139, guido=4127, jack=4098)\n" +"{'sape': 4139, 'guido': 4127, 'jack': 4098}" msgid "Looping Techniques" -msgstr "" +msgstr "Schleifentechniken" msgid "" "When looping through dictionaries, the key and corresponding value can be " "retrieved at the same time using the :meth:`~dict.items` method. ::" msgstr "" +"Beim Durchlaufen von Wörterbüchern können der Schlüssel und der zugehörige " +"Wert mithilfe der Methode :meth:`~dict.items`gleichzeitig abgerufen " +"werden. ::" msgid "" ">>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}\n" @@ -690,11 +1114,20 @@ msgid "" "gallahad the pure\n" "robin the brave" msgstr "" +">>> knights = {'gallahad': 'der Reine', 'robin': 'der Tapfere'}\n" +">>> for k, v in knights.items():\n" +"... print(k, v)\n" +"...\n" +"gallahad der Reine\n" +"robin der Tapfere" msgid "" "When looping through a sequence, the position index and corresponding value " "can be retrieved at the same time using the :func:`enumerate` function. ::" msgstr "" +"Beim Durchlaufen einer Sequenz können der Positionsindex und der zugehörige " +"Wert mithilfe der Funktion :func:`enumerate`gleichzeitig abgerufen " +"werden. ::" msgid "" ">>> for i, v in enumerate(['tic', 'tac', 'toe']):\n" @@ -704,11 +1137,19 @@ msgid "" "1 tac\n" "2 toe" msgstr "" +">>> for i, v in enumerate(['tic', 'tac', 'toe']):\n" +"... print(i, v)\n" +"...\n" +"0 tic\n" +"1 tac\n" +"2 toe" msgid "" "To loop over two or more sequences at the same time, the entries can be " "paired with the :func:`zip` function. ::" msgstr "" +"Um zwei oder mehr Sequenzen gleichzeitig zu durchlaufen, können die Einträge" +" mit der Funktion :func:`zip`gepaart werden. ::" msgid "" ">>> questions = ['name', 'quest', 'favorite color']\n" @@ -720,11 +1161,22 @@ msgid "" "What is your quest? It is the holy grail.\n" "What is your favorite color? It is blue." msgstr "" +">>> Fragen = ['Name', 'Aufgabe', 'Lieblingsfarbe']\n" +">>> Antworten = ['Lancelot', 'der Heilige Gral', 'blau']\n" +">>> for q, a in zip(Fragen, Antworten):\n" +"... print('Wie heißt du {0}? Du heißt {1}.'.format(q, a))\n" +"...\n" +"Wie heißt du? Du heißt Lancelot.\n" +"Was ist deine Aufgabe? Es ist der Heilige Gral.\n" +"Was ist deine Lieblingsfarbe? Es ist Blau." msgid "" "To loop over a sequence in reverse, first specify the sequence in a forward " "direction and then call the :func:`reversed` function. ::" msgstr "" +"Um eine Folge in umgekehrter Reihenfolge zu durchlaufen, geben Sie zunächst " +"die Folge in Vorwärtsrichtung an und rufen Sie anschließend die Funktion " +":func:`reversed`auf. ::" msgid "" ">>> for i in reversed(range(1, 10, 2)):\n" @@ -736,11 +1188,22 @@ msgid "" "3\n" "1" msgstr "" +">>> for i in reversed(range(1, 10, 2)):\n" +"... print(i)\n" +"...\n" +"9\n" +"7\n" +"5\n" +"3\n" +"1" msgid "" "To loop over a sequence in sorted order, use the :func:`sorted` function " "which returns a new sorted list while leaving the source unaltered. ::" msgstr "" +"Um eine Folge in sortierter Reihenfolge zu durchlaufen, verwenden Sie die " +"Funktion :func:`sorted` “, die eine neue sortierte Liste zurückgibt, " +"während die Quelle unverändert bleibt. ::" msgid "" ">>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']\n" @@ -754,13 +1217,27 @@ msgid "" "orange\n" "pear" msgstr "" +">>> basket = ['Apfel', 'Orange', 'Apfel', 'Birne', 'Orange', 'Banane']\n" +">>> for i in sorted(basket):\n" +"... print(i)\n" +"...\n" +"Apfel\n" +"Apfel\n" +"Banane\n" +"Orange\n" +"Orange\n" +"Birne" msgid "" -"Using :func:`set` on a sequence eliminates duplicate elements. The use of :" -"func:`sorted` in combination with :func:`set` over a sequence is an " -"idiomatic way to loop over unique elements of the sequence in sorted " -"order. ::" +"Using :func:`set` on a sequence eliminates duplicate elements. The use of " +":func:`sorted` in combination with :func:`set` over a sequence is an " +"idiomatic way to loop over unique elements of the sequence in sorted order. " +"::" msgstr "" +"Die Anwendung von :func:`set`auf eine Sequenz entfernt doppelte " +"Elemente. Die Verwendung von :func:`sorted`in Kombination mit " +":func:`set`auf eine Sequenz ist eine gängige Methode, um die eindeutigen " +"Elemente der Sequenz in sortierter Reihenfolge durchzugehen. ::" msgid "" ">>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']\n" @@ -772,11 +1249,22 @@ msgid "" "orange\n" "pear" msgstr "" +">>> basket = ['Apfel', 'Orange', 'Apfel', 'Birne', 'Orange', 'Banane']\n" +">>> for f in sorted(set(basket)):\n" +"... print(f)\n" +"...\n" +"Apfel\n" +"Banane\n" +"Orange\n" +"Birne" msgid "" "It is sometimes tempting to change a list while you are looping over it; " "however, it is often simpler and safer to create a new list instead. ::" msgstr "" +"Manchmal ist es verlockend, eine Liste zu ändern, während man sie in einer " +"Schleife durchläuft; oft ist es jedoch einfacher und sicherer, stattdessen " +"eine neue Liste zu erstellen. ::" msgid "" ">>> import math\n" @@ -789,14 +1277,25 @@ msgid "" ">>> filtered_data\n" "[56.2, 51.7, 55.3, 52.5, 47.8]" msgstr "" +">>> import math\n" +">>> raw_data = [56.2, float('NaN'), 51.7, 55.3, 52.5, float('NaN'), 47.8]\n" +">>> filtered_data = []\n" +">>> for value in raw_data:\n" +"... if not math.isnan(value):\n" +"... filtered_data.append(value)\n" +"...\n" +">>> filtered_data\n" +"[56,2, 51,7, 55,3, 52,5, 47,8]" msgid "More on Conditions" -msgstr "" +msgstr "Mehr zu den Bedingungen" msgid "" "The conditions used in ``while`` and ``if`` statements can contain any " "operators, not just comparisons." msgstr "" +"Die in den Anweisungen ``while``und ``if``verwendeten Bedingungen " +"können beliebige Operatoren enthalten, nicht nur Vergleichsoperatoren." msgid "" "The comparison operators ``in`` and ``not in`` are membership tests that " @@ -805,11 +1304,20 @@ msgid "" "object. All comparison operators have the same priority, which is lower " "than that of all numerical operators." msgstr "" +"Die Vergleichsoperatoren ``in``und ``not in``sind " +"Zugehörigkeitsprüfungen, die feststellen, ob ein Wert in einem Container " +"enthalten ist (oder nicht). Die Operatoren ``is``und ``is not``" +"vergleichen, ob zwei Objekte tatsächlich dasselbe Objekt sind. Alle " +"Vergleichsoperatoren haben dieselbe Priorität, die niedriger ist als die " +"aller numerischen Operatoren." msgid "" -"Comparisons can be chained. For example, ``a < b == c`` tests whether ``a`` " -"is less than ``b`` and moreover ``b`` equals ``c``." +"Comparisons can be chained. For example, ``a < b == c`` tests whether ``a``" +" is less than ``b`` and moreover ``b`` equals ``c``." msgstr "" +"Vergleiche können verkettet werden. Beispielsweise prüft ``a < b == c`` “," +" ob ``a``kleiner ist als ``b``und ob darüber hinaus ``b``" +"gleich ``c``ist." msgid "" "Comparisons may be combined using the Boolean operators ``and`` and ``or``, " @@ -819,20 +1327,37 @@ msgid "" "lowest, so that ``A and not B or C`` is equivalent to ``(A and (not B)) or " "C``. As always, parentheses can be used to express the desired composition." msgstr "" +"Vergleiche können mithilfe der Booleschen Operatoren ``and``und " +"``or``kombiniert werden, und das Ergebnis eines Vergleichs (oder eines " +"beliebigen anderen Booleschen Ausdrucks) kann mit ``not``negiert " +"werden. Diese haben eine niedrigere Priorität als Vergleichsoperatoren; " +"unter ihnen hat ``not``die höchste Priorität und ``or``die " +"niedrigste, sodass ``A and not B or C``gleichbedeutend ist mit ``(A " +"and (not B)) or C`` “. Wie immer können Klammern verwendet werden, um die " +"gewünschte Zusammensetzung auszudrücken." msgid "" "The Boolean operators ``and`` and ``or`` are so-called *short-circuit* " "operators: their arguments are evaluated from left to right, and evaluation " -"stops as soon as the outcome is determined. For example, if ``A`` and ``C`` " -"are true but ``B`` is false, ``A and B and C`` does not evaluate the " +"stops as soon as the outcome is determined. For example, if ``A`` and ``C``" +" are true but ``B`` is false, ``A and B and C`` does not evaluate the " "expression ``C``. When used as a general value and not as a Boolean, the " "return value of a short-circuit operator is the last evaluated argument." msgstr "" +"Die Booleschen Operatoren ``and`` und ``or`` sind sogenannte " +"*Kurzschluss*-Operatoren: Ihre Argumente werden von links nach rechts " +"ausgewertet, und die Auswertung wird beendet, sobald das Ergebnis feststeht." +" Sind beispielsweise ``A`` und ``C`` wahr, ``B`` jedoch falsch, so wertet " +"``A and B and C`` den Ausdruck ``C`` nicht aus. Wird ein " +"Kurzschlussoperator als allgemeiner Wert und nicht als Boolescher Wert " +"verwendet, ist der Rückgabewert das zuletzt ausgewertete Argument." msgid "" "It is possible to assign the result of a comparison or other Boolean " "expression to a variable. For example, ::" msgstr "" +"Es ist möglich, das Ergebnis eines Vergleichs oder eines anderen booleschen " +"Ausdrucks einer Variablen zuzuweisen. Beispiel: ::" msgid "" ">>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'\n" @@ -840,6 +1365,10 @@ msgid "" ">>> non_null\n" "'Trondheim'" msgstr "" +">>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'\n" +">>> non_null = string1 or string2 or string3\n" +">>> non_null\n" +"'Trondheim'" msgid "" "Note that in Python, unlike C, assignment inside expressions must be done " @@ -847,15 +1376,20 @@ msgid "" "an-expression>` ``:=``. This avoids a common class of problems encountered " "in C programs: typing ``=`` in an expression when ``==`` was intended." msgstr "" +"Beachten Sie, dass in Python – anders als in C – Zuweisungen innerhalb von " +"Ausdrücken explizit mit dem :ref:`Walross-Operator ` ``:=`` erfolgen müssen. Dadurch wird eine " +"häufige Problemklasse vermieden, die in C-Programmen auftritt: die Eingabe " +"von ``=`` in einem Ausdruck, obwohl eigentlich ``==`` gemeint war." msgid "Comparing Sequences and Other Types" -msgstr "" +msgstr "Vergleich von Sequenzen und anderen Typen" msgid "" "Sequence objects typically may be compared to other objects with the same " "sequence type. The comparison uses *lexicographical* ordering: first the " -"first two items are compared, and if they differ this determines the outcome " -"of the comparison; if they are equal, the next two items are compared, and " +"first two items are compared, and if they differ this determines the outcome" +" of the comparison; if they are equal, the next two items are compared, and " "so on, until either sequence is exhausted. If two items to be compared are " "themselves sequences of the same type, the lexicographical comparison is " "carried out recursively. If all items of two sequences compare equal, the " @@ -865,6 +1399,19 @@ msgid "" "order individual characters. Some examples of comparisons between sequences " "of the same type::" msgstr "" +"Sequenzobjekte können in der Regel mit anderen Objekten desselben " +"Sequenztyps verglichen werden. Der Vergleich erfolgt nach *lexikografischer*" +" Reihenfolge: Zunächst werden die ersten beiden Elemente verglichen; " +"unterscheiden sie sich, bestimmt dies das Ergebnis des Vergleichs; sind sie " +"gleich, werden die nächsten beiden Elemente verglichen und so weiter, bis " +"eine der beiden Sequenzen erschöpft ist. Sind zwei zu vergleichende Elemente" +" selbst Sequenzen desselben Typs, wird der lexikografische Vergleich " +"rekursiv durchgeführt. Sind alle Elemente zweier Sequenzen gleich, gelten " +"die Sequenzen als gleich. Ist eine Sequenz eine anfängliche Teilsequenz der " +"anderen, ist die kürzere Sequenz die kleinere (geringere). Bei der " +"lexikografischen Sortierung von Zeichenketten wird die Unicode-" +"Codepunktnummer zur Sortierung einzelner Zeichen verwendet. Einige Beispiele" +" für Vergleiche zwischen Sequenzen desselben Typs:" msgid "" "(1, 2, 3) < (1, 2, 4)\n" @@ -875,19 +1422,35 @@ msgid "" "(1, 2, 3) == (1.0, 2.0, 3.0)\n" "(1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4)" msgstr "" +"(1, 2, 3) < (1, 2, 4)\n" +"[1, 2, 3] < [1, 2, 4]\n" +"'ABC' < 'C' < 'Pascal' < 'Python'\n" +"(1, 2, 3, 4) < (1, 2, 4)\n" +"(1, 2) < (1, 2, -1)\n" +"(1, 2, 3) == (1,0, 2,0, 3,0)\n" +"(1, 2, ('aa', 'ab')) < (1, 2, ('abc', 'a'), 4)" msgid "" "Note that comparing objects of different types with ``<`` or ``>`` is legal " -"provided that the objects have appropriate comparison methods. For example, " -"mixed numeric types are compared according to their numeric value, so 0 " +"provided that the objects have appropriate comparison methods. For example," +" mixed numeric types are compared according to their numeric value, so 0 " "equals 0.0, etc. Otherwise, rather than providing an arbitrary ordering, " "the interpreter will raise a :exc:`TypeError` exception." msgstr "" +"Beachten Sie, dass der Vergleich von Objekten unterschiedlicher Typen mit " +"``<``oder ``>``zulässig ist, sofern die Objekte über entsprechende " +"Vergleichsmethoden verfügen. Beispielsweise werden gemischte numerische " +"Typen anhand ihres numerischen Werts verglichen, sodass 0 gleich 0,0 ist " +"usw. Andernfalls liefert der Interpreter keine willkürliche Reihenfolge, " +"sondern löst eine :exc:`TypeError` “-Ausnahme aus." msgid "Footnotes" msgstr "Fußnoten" msgid "" -"Other languages may return the mutated object, which allows method chaining, " -"such as ``d->insert(\"a\")->remove(\"b\")->sort();``." +"Other languages may return the mutated object, which allows method chaining," +" such as ``d->insert(\"a\")->remove(\"b\")->sort();``." msgstr "" +"Andere Sprachen geben möglicherweise das geänderte Objekt zurück, was eine " +"Methodenverkettung ermöglicht, wie beispielsweise " +"``d->insert(\"a\")->remove(\"b\")->sort();``." diff --git a/tutorial/errors.po b/tutorial/errors.po index 1c134e3..430d9be 100644 --- a/tutorial/errors.po +++ b/tutorial/errors.po @@ -29,8 +29,8 @@ msgid "" "tried out the examples you have probably seen some. There are (at least) " "two distinguishable kinds of errors: *syntax errors* and *exceptions*." msgstr "" -"Bis jetzt wurden Fehlermeldungen nur erwähnt, aber wenn Sie die Beispiele " -"ausprobiert haben, haben Sie wahrscheinlich einige gesehen. Es gibt " +"Bis jetzt wurden Fehlermeldungen nur erwähnt, aber wenn du die Beispiele " +"ausprobiert hast, hast du wahrscheinlich einige gesehen. Es gibt " "(mindestens) zwei Arten von Fehlern, die man unterscheiden kann: " "*Syntaxfehler* und *Ausnahmen*." @@ -74,7 +74,7 @@ msgid "" "you know where to look in case the input came from a file." msgstr "" "Der Dateiname (in unserem Beispiel ```` ) und die Zeilennummer " -"werden angezeigt, damit Sie wissen, wo Sie nachsehen müssen, falls die " +"werden angezeigt, damit du weisst, wo du nachsehen musst, falls die " "Eingabe aus einer Datei stammt." msgid "Exceptions" @@ -91,7 +91,7 @@ msgstr "" "Auch wenn eine Anweisung oder ein Ausdruck syntaktisch korrekt ist, kann es " "zu einem Fehler kommen, wenn man versucht, sie auszuführen. Fehler, die " "während der Ausführung entdeckt werden, werden *Ausnahmen* genannt und sind " -"nicht unbedingt fatal: Sie werden bald lernen, wie man sie in Python-" +"nicht unbedingt fatal: Du wirst bald lernen, wie man sie in Python-" "Programmen behandelt. Die meisten Ausnahmen werden jedoch nicht von " "Programmen behandelt und führen zu Fehlermeldungen wie hier gezeigt::" @@ -190,7 +190,7 @@ msgid "" "exception. ::" msgstr "" "Es ist möglich, Programme zu schreiben, die ausgewählte Ausnahmen behandeln. " -"Schauen Sie sich das folgende Beispiel an, das den Benutzer zur Eingabe " +"Schau dir das folgende Beispiel an, das den Benutzer zur Eingabe " "auffordert, bis ein gültiger Integer eingegeben wurde, dem Benutzer aber " "erlaubt, das Programm zu unterbrechen (mit :kbd:`Control-C` oder was auch " "immer das Betriebssystem unterstützt); beachte, dass eine vom Benutzer " @@ -335,9 +335,9 @@ msgid "" "it would have printed B, B, B --- the first matching *except clause* is " "triggered." msgstr "" -"Beachte, dass, wenn die *Exception-Klauseln* umgekehrt wären (mit " -"``except B`` zuerst), B, B, B ausgegeben worden wäre --- die erste passende " -"*Exception-Klausel* wird ausgelöst." +"Beachte: Wären die *except-Klauseln* vertauscht (mit ``except B`` an erster Stelle), " +"würde B, B, B ausgegeben werden – denn die erste passende *except-Klausel* wird " +"ausgelöst." msgid "" "When an exception occurs, it may have associated values, also known as the " @@ -573,8 +573,8 @@ msgid "" "handle it, a simpler form of the :keyword:`raise` statement allows you to re-" "raise the exception::" msgstr "" -"Wenn Sie feststellen müssen, ob eine Ausnahme ausgelöst wurde, aber nicht " -"beabsichtigen, sie zu behandeln, können Sie mit einer einfacheren Form der :" +"Wenn du feststellen musst, ob eine Ausnahme ausgelöst wurde, aber nicht " +"beabsichtigst, diese zu behandeln, kannst du mit einer einfacheren Form der :" "keyword:`raise` Anweisung die Ausnahme erneut auslösen::" msgid "" @@ -668,7 +668,7 @@ msgstr "" msgid "This can be useful when you are transforming exceptions. For example::" msgstr "" -"Dies kann nützlich sein, wenn Sie Ausnahmen umwandeln wollen. Zum Beispiel::" +"Dies kann nützlich sein, wenn du Ausnahmen umwandeln wikkst. Zum Beispiel::" msgid "" ">>> def func():\n" @@ -747,7 +747,7 @@ msgstr "" msgid "" "For more information about chaining mechanics, see :ref:`bltin-exceptions`." msgstr "" -"Weitere Informationen zur Verkettungsmechanik finden Sie unter :ref:`bltin-" +"Weitere Informationen zur Verkettungsmechanik findest du unter :ref:`bltin-" "exceptions`." msgid "User-defined Exceptions" diff --git a/tutorial/floatingpoint.po b/tutorial/floatingpoint.po index 986fae2..ed11f95 100644 --- a/tutorial/floatingpoint.po +++ b/tutorial/floatingpoint.po @@ -146,7 +146,7 @@ msgid "" "Just remember, even though the printed result looks like the exact value of " "1/10, the actual stored value is the nearest representable binary fraction." msgstr "" -"Denken Sie daran: Auch wenn das ausgegebene Ergebnis genau wie der Wert 1/10" +"Denke daran: Auch wenn das ausgegebene Ergebnis genau wie der Wert 1/10" " aussieht, ist der tatsächlich gespeicherte Wert der nächstgelegene " "darstellbare Binärbruch." @@ -197,7 +197,7 @@ msgid "" "For more pleasant output, you may wish to use string formatting to produce a" " limited number of significant digits:" msgstr "" -"Um die Ausgabe übersichtlicher zu gestalten, können Sie die " +"Um die Ausgabe übersichtlicher zu gestalten, kannst du die " "Zeichenfolgenformatierung verwenden, um eine begrenzte Anzahl signifikanter " "Stellen auszugeben:" @@ -302,7 +302,7 @@ msgstr "" "Problem mit \"0,1\“ wird weiter unten im Abschnitt \"Darstellungsfehler\“ " "ausführlich erläutert. Unter `Beispiele für Gleitkomma-Probleme " "`_ " -"finden Sie eine anschauliche Zusammenfassung der Funktionsweise der binären " +"findest du eine anschauliche Zusammenfassung der Funktionsweise der binären " "Gleitkommaarithmetik und der Arten von Problemen, die in der Praxis häufig " "auftreten. Siehe auch `Die Tücken der Gleitkommazahlen " "`_ für eine umfassendere " @@ -318,7 +318,7 @@ msgid "" "error." msgstr "" "Wie es gegen Ende heißt: \"Es gibt keine einfachen Antworten.\“ Dennoch " -"sollten Sie gegenüber Gleitkommazahlen nicht übermäßig misstrauisch sein! " +"solltest du gegenüber Gleitkommazahlen nicht übermäßig misstrauisch sein! " "Die Fehler bei Gleitkommaoperationen in Python stammen von der Gleitkomma-" "Hardware und liegen auf den meisten Rechnern bei höchstens 1 Teil pro " "2\\*\\*53 pro Operation. Das ist für die meisten Aufgaben mehr als " @@ -334,10 +334,10 @@ msgid "" ":meth:`str.format` method's format specifiers in :ref:`formatstrings`." msgstr "" "Es gibt zwar Ausnahmefälle, doch bei den meisten alltäglichen " -"Anwendungen der Gleitkommaarithmetik erhalten Sie letztendlich das erwartete" -" Ergebnis, wenn Sie die Anzeige Ihrer Endergebnisse einfach auf die " -"gewünschte Anzahl von Dezimalstellen runden. :func:`str` reicht in der " -"Regel aus; für eine feinere Steuerung finden Sie die Formatbezeichner der " +"Anwendungen der Gleitkommaarithmetik erhältst du letztendlich das erwartete" +" Ergebnis, wenn du die Anzeige deiner Endergebnisse einfach auf die " +"gewünschte Anzahl von Dezimalstellen rundest. :func:`str` reicht in der " +"Regel aus; für eine feinere Steuerung findest du die Formatbezeichner der " "Methode :meth:`str.format` unter :ref:`formatstrings`." msgid "" @@ -345,8 +345,8 @@ msgid "" ":mod:`decimal` module which implements decimal arithmetic suitable for " "accounting applications and high-precision applications." msgstr "" -"Für Anwendungsfälle, die eine exakte Dezimaldarstellung erfordern, sollten " -"Sie das Modul :mod:`decimal` verwenden, das eine Dezimalarithmetik " +"Für Anwendungsfälle, die eine exakte Dezimaldarstellung erfordern, solltest " +"du das Modul :mod:`decimal` verwenden, das eine Dezimalarithmetik " "implementiert, die für Buchhaltungsanwendungen und Anwendungen mit hoher " "Genauigkeit geeignet ist." @@ -365,7 +365,7 @@ msgid "" "statistical operations supplied by the SciPy project. See " "." msgstr "" -"Wenn Sie häufig mit Gleitkommaoperationen arbeiten, sollten Sie sich das " +"Wenn du häufig mit Gleitkommaoperationen arbeitest, solltest du das " "NumPy-Paket sowie viele andere Pakete für mathematische und statistische " "Operationen ansehen, die vom SciPy-Projekt bereitgestellt werden. Siehe " "." @@ -523,7 +523,7 @@ msgid "" "with binary floating-point representation is assumed." msgstr "" "In diesem Abschnitt wird das Beispiel \"0.1\“ ausführlich erläutert und " -"gezeigt, wie Sie Fälle wie diesen selbst genau analysieren können. " +"gezeigt, wie du Fälle wie diesen selbst genau analysieren kannst. " "Grundkenntnisse über die binäre Gleitkommadarstellung werden vorausgesetzt." msgid "" diff --git a/tutorial/inputoutput.po b/tutorial/inputoutput.po index c8142ca..ab62c85 100644 --- a/tutorial/inputoutput.po +++ b/tutorial/inputoutput.po @@ -17,38 +17,57 @@ msgstr "" "Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" + msgid "Input and Output" -msgstr "" +msgstr "Eingabe und Ausgabe" msgid "" "There are several ways to present the output of a program; data can be " "printed in a human-readable form, or written to a file for future use. This " "chapter will discuss some of the possibilities." msgstr "" +"Es gibt verschiedene Möglichkeiten, die Ausgabe eines Programms " +"darzustellen; Daten können in einer für Menschen lesbaren Form ausgegeben " +"oder zur späteren Verwendung in eine Datei geschrieben werden. In diesem " +"Kapitel werden einige dieser Möglichkeiten behandelt." msgid "Fancier Output Formatting" -msgstr "" +msgstr "Erweiterte Formatierungsmöglichkeiten für die Ausgabe" msgid "" -"So far we've encountered two ways of writing values: *expression statements* " -"and the :func:`print` function. (A third way is using the :meth:`~io." -"TextIOBase.write` method of file objects; the standard output file can be " -"referenced as ``sys.stdout``. See the Library Reference for more information " -"on this.)" +"So far we've encountered two ways of writing values: *expression statements*" +" and the :func:`print` function. (A third way is using the " +":meth:`~io.TextIOBase.write` method of file objects; the standard output " +"file can be referenced as ``sys.stdout``. See the Library Reference for more" +" information on this.)" msgstr "" +"Bisher haben wir zwei Möglichkeiten kennengelernt, Werte zu schreiben: " +"*Ausdrucksanweisungen* und die Funktion:func:`print`. (Eine dritte " +"Möglichkeit ist die Verwendung der Methode:meth:`~io.TextIOBase.write` " +"von Datei-Objekten; auf die Standardausgabedatei kann als``sys.stdout``" +"verwiesen werden. Weitere Informationen hierzu findest du in der " +"Bibliotheksreferenz.)" msgid "" "Often you'll want more control over the formatting of your output than " "simply printing space-separated values. There are several ways to format " "output." msgstr "" +"Oftmals möchtest du mehr Kontrolle über die Formatierung Ihrer Ausgabe " +"haben, als nur durch Leerzeichen getrennte Werte auszugeben. Es gibt " +"verschiedene Möglichkeiten, die Ausgabe zu formatieren." msgid "" -"To use :ref:`formatted string literals `, begin a string with " -"``f`` or ``F`` before the opening quotation mark or triple quotation mark. " -"Inside this string, you can write a Python expression between ``{`` and ``}" -"`` characters that can refer to variables or literal values." +"To use :ref:`formatted string literals `, begin a string with" +" ``f`` or ``F`` before the opening quotation mark or triple quotation mark. " +"Inside this string, you can write a Python expression between ``{`` and " +"``}`` characters that can refer to variables or literal values." msgstr "" +"Um :ref:`formatierte Zeichenfolgenliterale ` zu verwenden, " +"beginne eine Zeichenfolge mit ``f`` oder ``F`` vor dem öffnenden " +"Anführungszeichen oder dem dreifachen Anführungszeichen. Innerhalb dieser " +"Zeichenfolge kannst du einen Python-Ausdruck zwischen den Zeichen ``{`` und" +" ``}`` schreiben, der sich auf Variablen oder Literalwerte beziehen kann." msgid "" ">>> year = 2016\n" @@ -56,14 +75,24 @@ msgid "" ">>> f'Results of the {year} {event}'\n" "'Results of the 2016 Referendum'" msgstr "" +">>> year = 2016\n" +">>> event = 'Referendum'\n" +">>> f'Ergebnisse des {year} {event} '\n" +"'Ergebnisse des Referendums von 2016'" msgid "" "The :meth:`str.format` method of strings requires more manual effort. " "You'll still use ``{`` and ``}`` to mark where a variable will be " "substituted and can provide detailed formatting directives, but you'll also " -"need to provide the information to be formatted. In the following code block " -"there are two examples of how to format variables:" +"need to provide the information to be formatted. In the following code block" +" there are two examples of how to format variables:" msgstr "" +"Die Methode :meth:`str.format` für Zeichenketten erfordert mehr " +"manuellen Aufwand. Verwende weiterhin ``{`` und ``}``, um zu " +"kennzeichnen, an welcher Stelle eine Variable eingefügt werden soll, und " +"können detaillierte Formatierungsanweisungen angeben, müssen jedoch " +"zusätzlich die zu formatierenden Informationen bereitstellen. Im folgenden " +"Codeblock findest du zwei Beispiele für die Formatierung von Variablen:" msgid "" ">>> yes_votes = 42_572_654\n" @@ -72,40 +101,69 @@ msgid "" ">>> '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage)\n" "' 42572654 YES votes 49.67%'" msgstr "" +">>> yes_votes = 42_572_654\n" +">>> total_votes = 85_705_149\n" +">>> prozent = Ja-Stimmen / Gesamtstimmen\n" +">>> '{:-9} Ja-Stimmen {:2,2 %}'.format(Ja-Stimmen, prozent)\n" +"' 42.572.654 Ja-Stimmen 49,67 %'" msgid "" -"Notice how the ``yes_votes`` are padded with spaces and a negative sign only " -"for negative numbers. The example also prints ``percentage`` multiplied by " -"100, with 2 decimal places and followed by a percent sign (see :ref:" -"`formatspec` for details)." +"Notice how the ``yes_votes`` are padded with spaces and a negative sign only" +" for negative numbers. The example also prints ``percentage`` multiplied by " +"100, with 2 decimal places and followed by a percent sign (see " +":ref:`formatspec` for details)." msgstr "" +"Beachte, dass die ``yes_votes`` nur bei negativen Zahlen mit " +"Leerzeichen und einem Minuszeichen aufgefüllt werden. Das Beispiel gibt " +"außerdem ``percentage`` multipliziert mit 100 aus, mit zwei " +"Dezimalstellen und einem Prozentzeichen am Ende (weitere Informationen " +"findest du unter :ref:`formatspec` )." msgid "" -"Finally, you can do all the string handling yourself by using string slicing " -"and concatenation operations to create any layout you can imagine. The " +"Finally, you can do all the string handling yourself by using string slicing" +" and concatenation operations to create any layout you can imagine. The " "string type has some methods that perform useful operations for padding " "strings to a given column width." msgstr "" +"Schließlich kannst du die gesamte Zeichenfolgenbearbeitung selbst " +"übernehmen, indem du Zeichenfolgenausschnitte und Verkettungsoperationen " +"nutzen tust, um jedes erdenkliche Layout zu erstellen. Der Typ \"Zeichenfolge\“ " +"verfügt über einige Methoden, mit denen sich Zeichenfolgen auf eine " +"bestimmte Spaltenbreite auffüllen lassen." msgid "" "When you don't need fancy output but just want a quick display of some " -"variables for debugging purposes, you can convert any value to a string with " -"the :func:`repr` or :func:`str` functions." +"variables for debugging purposes, you can convert any value to a string with" +" the :func:`repr` or :func:`str` functions." msgstr "" +"Wenn du keine aufwendige Ausgabe benötigst, sondern lediglich eine schnelle" +" Anzeige einiger Variablen zu Debugging-Zwecken wünschen, kannst du jeden " +"Wert mit den Funktionen :func:`repr` oder :func:`str` in eine " +"Zeichenkette umwandeln." msgid "" "The :func:`str` function is meant to return representations of values which " "are fairly human-readable, while :func:`repr` is meant to generate " -"representations which can be read by the interpreter (or will force a :exc:" -"`SyntaxError` if there is no equivalent syntax). For objects which don't " -"have a particular representation for human consumption, :func:`str` will " -"return the same value as :func:`repr`. Many values, such as numbers or " -"structures like lists and dictionaries, have the same representation using " +"representations which can be read by the interpreter (or will force a " +":exc:`SyntaxError` if there is no equivalent syntax). For objects which " +"don't have a particular representation for human consumption, :func:`str` " +"will return the same value as :func:`repr`. Many values, such as numbers or" +" structures like lists and dictionaries, have the same representation using " "either function. Strings, in particular, have two distinct representations." msgstr "" +"Die Funktion :func:`str` soll Darstellungen von Werten zurückgeben, die " +"für Menschen gut lesbar sind, während :func:`repr` dazu dient, " +"Darstellungen zu generieren, die vom Interpreter gelesen werden können (oder" +" einen :exc:`SyntaxError` auslösen, falls keine entsprechende Syntax " +"vorhanden ist). Bei Objekten, für die es keine spezielle Darstellung für " +"Menschen gibt, gibt:func:`str` denselben Wert zurück wie " +":func:`repr`. Viele Werte, wie beispielsweise Zahlen oder Strukturen wie " +"Listen und Wörterbücher, werden von beiden Funktionen auf dieselbe Weise " +"dargestellt. Insbesondere Zeichenketten haben zwei unterschiedliche " +"Darstellungen." msgid "Some examples::" -msgstr "" +msgstr "Einige Beispiele:" msgid "" ">>> s = 'Hello, world.'\n" @@ -129,17 +187,43 @@ msgid "" ">>> repr((x, y, ('spam', 'eggs')))\n" "\"(32.5, 40000, ('spam', 'eggs'))\"" msgstr "" +">>> s = 'Hallo, Welt.'\n" +">>> str(s)\n" +"'Hallo, Welt.'\n" +">>> repr(s)\n" +"\"'Hallo, Welt.'\"\n" +">>> str(1/7)\n" +"'0,14285714285714285'\n" +">>> x = 10 * 3,25\n" +">>> y = 200 * 200\n" +">>> s = 'Der Wert von x ist ' + repr(x) + ', und y ist ' + repr(y) + '...'\n" +">>> print(s)\n" +"Der Wert von x ist 32,5 und der von y ist 40000...\n" +">>> # Die Funktion repr() fügt bei einer Zeichenkette Anführungszeichen und Backslashes hinzu:\n" +">>> hello = 'hello, world\\n'\n" +">>> hellos = repr(hello)\n" +">>> print(hellos)\n" +"'hello, world\\n'\n" +">>> # Das Argument für repr() kann ein beliebiges Python-Objekt sein:\n" +">>> repr((x, y, ('spam', 'eggs')))\n" +"\"(32.5, 40000, ('spam', 'eggs'))\"" msgid "" "The :mod:`string` module contains support for a simple templating approach " "based upon regular expressions, via :class:`string.Template`. This offers " "yet another way to substitute values into strings, using placeholders like " -"``$x`` and replacing them with values from a dictionary. This syntax is easy " -"to use, although it offers much less control for formatting." +"``$x`` and replacing them with values from a dictionary. This syntax is easy" +" to use, although it offers much less control for formatting." msgstr "" +"Das Modul :mod:`string` bietet Unterstützung für einen einfachen " +"Template-Ansatz auf Basis regulärer Ausdrücke über " +":class:`string.Template`. Dies bietet eine weitere Möglichkeit, Werte in " +"Zeichenfolgen einzufügen, indem Platzhalter wie ``$x`` verwendet und " +"durch Werte aus einem Wörterbuch ersetzt werden. Diese Syntax ist einfach zu" +" verwenden, bietet jedoch deutlich weniger Kontrolle über die Formatierung." msgid "Formatted String Literals" -msgstr "" +msgstr "Formatierte Zeichenfolgenliterale" msgid "" ":ref:`Formatted string literals ` (also called f-strings for " @@ -147,23 +231,36 @@ msgid "" "prefixing the string with ``f`` or ``F`` and writing expressions as " "``{expression}``." msgstr "" +":ref:`Mit formatierten String-Literalen ` (kurz auch als " +"f-Strings bezeichnet) kannst du den Wert von Python-Ausdrücken in einen " +"String einfügen, indem du dem String die Präfixe ``f`` oder ``F`` " +"voranstellen und Ausdrücke in der Form ``{expression}`` schreibst." msgid "" "An optional format specifier can follow the expression. This allows greater " "control over how the value is formatted. The following example rounds pi to " "three places after the decimal::" msgstr "" +"Dem Ausdruck kann ein optionaler Formatbezeichner folgen. Dies ermöglicht " +"eine genauere Steuerung der Formatierung des Werts. Im folgenden Beispiel " +"wird Pi auf drei Stellen nach dem Komma gerundet::" msgid "" ">>> import math\n" ">>> print(f'The value of pi is approximately {math.pi:.3f}.')\n" "The value of pi is approximately 3.142." msgstr "" +">>> import math\n" +">>> print(f'Der Wert von Pi beträgt ungefähr {math.pi:.3f}.')\n" +"Der Wert von Pi beträgt ungefähr 3,142." msgid "" "Passing an integer after the ``':'`` will cause that field to be a minimum " "number of characters wide. This is useful for making columns line up. ::" msgstr "" +"Wird nach dem Befehl ``':'`` eine Ganzzahl übergeben, wird die Breite " +"dieses Feldes auf die angegebene Mindestanzahl an Zeichen festgelegt. Dies " +"ist nützlich, um Spalten auszurichten. ::" msgid "" ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}\n" @@ -174,12 +271,23 @@ msgid "" "Jack ==> 4098\n" "Dcab ==> 7678" msgstr "" +">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}\n" +">>> for name, phone in table.items():\n" +"... print(f'{name:10} ==> {phone:10d}')\n" +"...\n" +"Sjoerd ==> 4127\n" +"Jack ==> 4098\n" +"Dcab ==> 7678" msgid "" -"Other modifiers can be used to convert the value before it is formatted. ``'!" -"a'`` applies :func:`ascii`, ``'!s'`` applies :func:`str`, and ``'!r'`` " +"Other modifiers can be used to convert the value before it is formatted. " +"``'!a'`` applies :func:`ascii`, ``'!s'`` applies :func:`str`, and ``'!r'`` " "applies :func:`repr`::" msgstr "" +"Es können weitere Modifikatoren verwendet werden, um den Wert vor der " +"Formatierung umzuwandeln. ``'!a'`` wendet :func:`ascii` an, " +"``'!s'`` wendet :func:`str` an und ``'!r'`` wendet :func:`repr` " +"an ::" msgid "" ">>> animals = 'eels'\n" @@ -188,36 +296,57 @@ msgid "" ">>> print(f'My hovercraft is full of {animals!r}.')\n" "My hovercraft is full of 'eels'." msgstr "" +">>> animals = 'Aale'\n" +">>> print(f'Mein Luftkissenfahrzeug ist voll mit {animals}.')\n" +"Mein Luftkissenfahrzeug ist voll mit Aalen.\n" +">>> print(f'Mein Luftkissenfahrzeug ist voll mit {animals!r}.')\n" +"Mein Luftkissenfahrzeug ist voll mit 'Aalen'." msgid "" "The ``=`` specifier can be used to expand an expression to the text of the " "expression, an equal sign, then the representation of the evaluated " "expression:" msgstr "" +"Mit dem Bezeichner ``=`` lässt sich ein Ausdruck so erweitern, dass er " +"zunächst den Text des Ausdrucks, dann ein Gleichheitszeichen und " +"anschließend die Darstellung des ausgewerteten Ausdrucks enthält:" msgid "" "See :ref:`self-documenting expressions ` for more " "information on the ``=`` specifier. For a reference on these format " "specifications, see the reference guide for the :ref:`formatspec`." msgstr "" +"Weitere Informationen zum Spezifizierer ``=`` findest du unter " +":ref:`selbstdokumentierende Ausdrücke `. Eine Übersicht " +"über diese Formatvorgaben findest du im Referenzhandbuch unter " +":ref:`formatspec`." msgid "The String format() Method" -msgstr "" +msgstr "Die String-Methode \"format()\“" msgid "Basic usage of the :meth:`str.format` method looks like this::" msgstr "" +"Die grundlegende Verwendung der Methode :meth:`str.format` sieht wie " +"folgt aus::" msgid "" ">>> print('We are the {} who say \"{}!\"'.format('knights', 'Ni'))\n" "We are the knights who say \"Ni!\"" msgstr "" +">>> print('Wir sind die {}, die \"{}!\“ sagen'.format('Ritter', 'Ni'))\n" +"Wir sind die Ritter, die \"Ni!\“ sagen" msgid "" "The brackets and characters within them (called format fields) are replaced " -"with the objects passed into the :meth:`str.format` method. A number in the " -"brackets can be used to refer to the position of the object passed into the :" -"meth:`str.format` method. ::" +"with the objects passed into the :meth:`str.format` method. A number in the" +" brackets can be used to refer to the position of the object passed into the" +" :meth:`str.format` method. ::" msgstr "" +"Die Klammern und die darin enthaltenen Zeichen (sogenannte Formatfelder) " +"werden durch die an die Methode :meth:`str.format` übergebenen Objekte " +"ersetzt. Eine Zahl in den Klammern kann verwendet werden, um auf die " +"Position des an die Methode :meth:`str.format` übergebenen Objekts zu " +"verweisen. ::" msgid "" ">>> print('{0} and {1}'.format('spam', 'eggs'))\n" @@ -225,26 +354,39 @@ msgid "" ">>> print('{1} and {0}'.format('spam', 'eggs'))\n" "eggs and spam" msgstr "" +">>> print('{0} und {1}'.format('Spam', 'Eier'))\n" +"Spam und Eier\n" +">>> print('{1} und {0}'.format('Spam', 'Eier'))\n" +"Eier und Spam" msgid "" -"If keyword arguments are used in the :meth:`str.format` method, their values " -"are referred to by using the name of the argument. ::" +"If keyword arguments are used in the :meth:`str.format` method, their values" +" are referred to by using the name of the argument. ::" msgstr "" +"Werden in der Methode :meth:`str.format` Schlüsselwortargumente " +"verwendet, wird auf deren Werte über den Namen des Arguments verwiesen. ::" msgid "" ">>> print('This {food} is {adjective}.'.format(\n" "... food='spam', adjective='absolutely horrible'))\n" "This spam is absolutely horrible." msgstr "" +">>> print('Diese {food} lautet {adjective}.'.format(\n" +"... food='Spam', adjective='absolut schrecklich'))\n" +"Dieser Spam ist absolut schrecklich." msgid "Positional and keyword arguments can be arbitrarily combined::" msgstr "" +"Positions- und Schlüsselwortargumente können beliebig kombiniert werden::" msgid "" ">>> print('The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred',\n" "... other='Georg'))\n" "The story of Bill, Manfred, and Georg." msgstr "" +">>> print('Die Geschichte von {0}, {1} und {other}.'.format('Bill', 'Manfred',\n" +"... other='Georg'))\n" +"Die Geschichte von Bill, Manfred und Georg." msgid "" "If you have a really long format string that you don't want to split up, it " @@ -252,6 +394,12 @@ msgid "" "instead of by position. This can be done by simply passing the dict and " "using square brackets ``'[]'`` to access the keys. ::" msgstr "" +"Wenn du eine wirklich lange Formatzeichenfolge hast, die du nicht " +"aufteilen möchtest, wäre es praktisch, wenn du die zu formatierenden " +"Variablen nicht anhand ihrer Position, sondern anhand ihres Namens " +"referenzieren könntest. Dies lässt sich erreichen, indem du einfach das " +"Wörterbuch übergibst und eckige Klammern ``'[]'`` verwendest, um auf die " +"Schlüssel zuzugreifen. ::" msgid "" ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n" @@ -259,23 +407,34 @@ msgid "" "... 'Dcab: {0[Dcab]:d}'.format(table))\n" "Jack: 4098; Sjoerd: 4127; Dcab: 8637678" msgstr "" +">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n" +">>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '\n" +"... 'Dcab: {0[Dcab]:d}'.format(table))\n" +"Jack: 4098; Sjoerd: 4127; Dcab: 8637678" msgid "" "This could also be done by passing the ``table`` dictionary as keyword " "arguments with the ``**`` notation. ::" msgstr "" +"Dies könnte auch erreicht werden, indem das Wörterbuch ``table`` als " +"Schlüsselwortargumente mit der Notation ``**`` übergeben wird. ::" msgid "" ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n" -">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'." -"format(**table))\n" +">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))\n" "Jack: 4098; Sjoerd: 4127; Dcab: 8637678" msgstr "" +">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n" +">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))\n" +"Jack: 4098; Sjoerd: 4127; Dcab: 8637678" msgid "" -"This is particularly useful in combination with the built-in function :func:" -"`vars`, which returns a dictionary containing all local variables::" +"This is particularly useful in combination with the built-in function " +":func:`vars`, which returns a dictionary containing all local variables::" msgstr "" +"Dies ist besonders nützlich in Kombination mit der integrierten Funktion" +":func:`vars`, die ein Wörterbuch zurückgibt, das alle lokalen Variablen " +"enthält::" msgid "" ">>> table = {k: str(v) for k, v in vars().items()}\n" @@ -283,11 +442,18 @@ msgid "" ">>> print(message.format(**table))\n" "__name__: __main__; __doc__: None; __package__: None; __loader__: ..." msgstr "" +">>> table = {k: str(v) for k, v in vars().items()}\n" +">>> message = \" \".join([f'{k}: ' + '{' + k + '};' for k in table.keys()])\n" +">>> print(message.format(**table))\n" +"__name__: __main__; __doc__: None; __package__: None; __loader__: ..." msgid "" "As an example, the following lines produce a tidily aligned set of columns " "giving integers and their squares and cubes::" msgstr "" +"Die folgenden Zeilen erzeugen beispielsweise eine übersichtlich " +"ausgerichtete Spaltenreihe, in der Ganzzahlen sowie deren Quadrate und " +"Kubikzahlen aufgeführt sind::" msgid "" ">>> for x in range(1, 11):\n" @@ -304,17 +470,34 @@ msgid "" " 9 81 729\n" "10 100 1000" msgstr "" +">>> for x in range(1, 11):\n" +"... print('{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x))\n" +"...\n" +" 1 1 1\n" +" 2 4 8\n" +" 3 9 27\n" +" 4 16 64\n" +" 5 25 125\n" +" 6 36 216\n" +" 7 49 343\n" +" 8 64 512\n" +" 9 81 729\n" +"10 100 1000" msgid "" -"For a complete overview of string formatting with :meth:`str.format`, see :" -"ref:`formatstrings`." +"For a complete overview of string formatting with :meth:`str.format`, see " +":ref:`formatstrings`." msgstr "" +"Einen vollständigen Überblick über die Zeichenfolgenformatierung mit " +":meth:`str.format` findest du unter :ref:`formatstrings`." msgid "Manual String Formatting" -msgstr "" +msgstr "Manuelle Formatierung von Zeichenfolgen" msgid "Here's the same table of squares and cubes, formatted manually::" msgstr "" +"Hier ist dieselbe Tabelle mit Quadraten und Würfeln, die manuell formatiert " +"wurde::" msgid "" ">>> for x in range(1, 11):\n" @@ -333,27 +516,57 @@ msgid "" " 9 81 729\n" "10 100 1000" msgstr "" +">>> for x in range(1, 11):\n" +"... print(repr(x).rjust(2), repr(x*x).rjust(3), end=' ')\n" +"... # Beachte die Verwendung von \"end\“ in der vorherigen Zeile\n" +"... print(repr(x*x*x).rjust(4))\n" +"...\n" +" 1 1 1\n" +" 2 4 8\n" +" 3 9 27\n" +" 4 16 64\n" +" 5 25 125\n" +" 6 36 216\n" +" 7 49 343\n" +" 8 64 512\n" +" 9 81 729\n" +"10 100 1000" msgid "" -"(Note that the one space between each column was added by the way :func:" -"`print` works: it always adds spaces between its arguments.)" +"(Note that the one space between each column was added by the way " +":func:`print` works: it always adds spaces between its arguments.)" msgstr "" +"(Beachte, dass das einzelne Leerzeichen zwischen den einzelnen Spalten " +"durch die Funktionsweise von :func:`print` hinzugefügt wurde: Diese " +"Funktion fügt immer Leerzeichen zwischen ihren Argumenten ein.)" msgid "" -"The :meth:`str.rjust` method of string objects right-justifies a string in a " -"field of a given width by padding it with spaces on the left. There are " +"The :meth:`str.rjust` method of string objects right-justifies a string in a" +" field of a given width by padding it with spaces on the left. There are " "similar methods :meth:`str.ljust` and :meth:`str.center`. These methods do " "not write anything, they just return a new string. If the input string is " -"too long, they don't truncate it, but return it unchanged; this will mess up " -"your column lay-out but that's usually better than the alternative, which " +"too long, they don't truncate it, but return it unchanged; this will mess up" +" your column lay-out but that's usually better than the alternative, which " "would be lying about a value. (If you really want truncation you can always " "add a slice operation, as in ``x.ljust(n)[:n]``.)" msgstr "" +"Die Methode :meth:`str.rjust` von String-Objekten richtet eine " +"Zeichenkette in einem Feld mit einer bestimmten Breite rechtsbündig aus, " +"indem sie links mit Leerzeichen aufgefüllt wird. Es gibt ähnliche Methoden: " +" :meth:`str.ljust` und :meth:`str.center`. Diese Methoden schreiben " +"nichts, sondern geben lediglich eine neue Zeichenkette zurück. Ist die " +"Eingabezeichenkette zu lang, wird sie nicht gekürzt, sondern unverändert " +"zurückgegeben; dies bringt zwar das Spaltenlayout durcheinander, ist aber in" +" der Regel besser als die Alternative, bei der ein Wert falsch dargestellt " +"würde. (Wenn du wirklich eine Kürzung wünschst, kannst du jederzeit eine " +"Slice-Operation hinzufügen, wie in ``x.ljust(n)[:n]`` beschrieben.)" msgid "" "There is another method, :meth:`str.zfill`, which pads a numeric string on " "the left with zeros. It understands about plus and minus signs::" msgstr "" +"Es gibt noch eine weitere Methode, :meth:`str.zfill`, die eine numerische " +"Zeichenkette links mit Nullen auffüllt. Sie erkennt Plus- und Minuszeichen::" msgid "" ">>> '12'.zfill(5)\n" @@ -363,9 +576,15 @@ msgid "" ">>> '3.14159265359'.zfill(5)\n" "'3.14159265359'" msgstr "" +">>> '12'.zfill(5)\n" +"'00012'\n" +">>> '-3.14'.zfill(7)\n" +"'-003,14'\n" +">>> '3,14159265359'.zfill(5)\n" +"'3,14159265359'" msgid "Old string formatting" -msgstr "" +msgstr "Alte Zeichenfolgenformatierung" msgid "" "The % operator (modulo) can also be used for string formatting. Given " @@ -374,32 +593,46 @@ msgid "" "*values*. This operation is commonly known as string interpolation. For " "example::" msgstr "" +"Der %-Operator (Modulo) kann auch zur Formatierung von Zeichenketten " +"verwendet werden. Bei der Angabe von ``format % values`` (wobei *format*" +" eine Zeichenkette ist) werden die Konvertierungsspezifikationen ``%`` " +"in *format* durch null oder mehr Elemente aus *values* ersetzt. Dieser " +"Vorgang wird allgemein als Zeichenketteninterpolation bezeichnet. Zum " +"Beispiel::" msgid "" ">>> import math\n" ">>> print('The value of pi is approximately %5.3f.' % math.pi)\n" "The value of pi is approximately 3.142." msgstr "" +">>> import math\n" +">>> print('Der Wert von Pi beträgt ungefähr %5.3f.' % math.pi)\n" +"Der Wert von Pi beträgt ungefähr 3,142." msgid "" "More information can be found in the :ref:`old-string-formatting` section." msgstr "" +"Weitere Informationen findest du im Abschnitt :ref:`old-string-formatting`" +"." msgid "Reading and Writing Files" -msgstr "" +msgstr "Dateien lesen und schreiben" msgid "" ":func:`open` returns a :term:`file object`, and is most commonly used with " "two positional arguments and one keyword argument: ``open(filename, mode, " "encoding=None)``" msgstr "" +":func:`open` gibt ein :term:`Dateiobjekt` zurück und wird meist mit zwei " +"Positionsargumenten und einem Schlüsselwortargument verwendet: " +"``open(filename, mode, encoding=None)``" msgid ">>> f = open('workfile', 'w', encoding=\"utf-8\")" -msgstr "" +msgstr ">>> f = open('workfile', 'w', encoding=\"utf-8\")" msgid "" -"The first argument is a string containing the filename. The second argument " -"is another string containing a few characters describing the way in which " +"The first argument is a string containing the filename. The second argument" +" is another string containing a few characters describing the way in which " "the file will be used. *mode* can be ``'r'`` when the file will only be " "read, ``'w'`` for only writing (an existing file with the same name will be " "erased), and ``'a'`` opens the file for appending; any data written to the " @@ -407,35 +640,68 @@ msgid "" "reading and writing. The *mode* argument is optional; ``'r'`` will be " "assumed if it's omitted." msgstr "" +"Das erste Argument ist eine Zeichenkette, die den Dateinamen enthält. Das " +"zweite Argument ist eine weitere Zeichenkette, die einige Zeichen enthält, " +"die beschreiben, wie die Datei verwendet wird. *mode* kann ``'r'`` " +"lauten, wenn die Datei nur gelesen wird, ``'w'`` für das reine Schreiben" +" (eine bereits vorhandene Datei mit demselben Namen wird dabei gelöscht) und" +" ``'a'`` öffnet die Datei zum Anhängen; alle in die Datei geschriebenen " +"Daten werden automatisch am Ende angehängt. ``'r+'`` öffnet die Datei " +"sowohl zum Lesen als auch zum Schreiben. Das Argument *mode* ist optional; " +"wird es weggelassen, wird ``'r'`` angenommen." msgid "" "Normally, files are opened in :dfn:`text mode`, that means, you read and " "write strings from and to the file, which are encoded in a specific " "*encoding*. If *encoding* is not specified, the default is platform " -"dependent (see :func:`open`). Because UTF-8 is the modern de-facto standard, " -"``encoding=\"utf-8\"`` is recommended unless you know that you need to use a " -"different encoding. Appending a ``'b'`` to the mode opens the file in :dfn:" -"`binary mode`. Binary mode data is read and written as :class:`bytes` " +"dependent (see :func:`open`). Because UTF-8 is the modern de-facto standard," +" ``encoding=\"utf-8\"`` is recommended unless you know that you need to use " +"a different encoding. Appending a ``'b'`` to the mode opens the file in " +":dfn:`binary mode`. Binary mode data is read and written as :class:`bytes` " "objects. You can not specify *encoding* when opening file in binary mode." msgstr "" +"Normalerweise werden Dateien im :dfn:`Textmodus` geöffnet, das heißt, du " +"liest Zeichenketten aus der Datei aus und schreibst Zeichenketten in die " +"Datei, die in einer bestimmten *Kodierung* kodiert sind. Wenn keine " +"*Kodierung* angegeben ist, ist die Standardeinstellung plattformabhängig " +"(siehe :func:`open`). Da UTF-8 der moderne De-facto-Standard ist, wird " +"``encoding=\"utf-8\"`` empfohlen, es sei denn, du weisst, dass du eine " +"andere Kodierung verwenden musst. Durch Hinzufügen eines ``'b'`` zum Modus " +"wird die Datei im :dfn:`Binärmodus` geöffnet. Daten im Binärmodus werden als" +" :class:`bytes` -Objekte gelesen und geschrieben. Beim Öffnen einer Datei im" +" Binärmodus kannst du keine *Kodierung* angeben." msgid "" "In text mode, the default when reading is to convert platform-specific line " "endings (``\\n`` on Unix, ``\\r\\n`` on Windows) to just ``\\n``. When " "writing in text mode, the default is to convert occurrences of ``\\n`` back " "to platform-specific line endings. This behind-the-scenes modification to " -"file data is fine for text files, but will corrupt binary data like that in :" -"file:`JPEG` or :file:`EXE` files. Be very careful to use binary mode when " +"file data is fine for text files, but will corrupt binary data like that in " +":file:`JPEG` or :file:`EXE` files. Be very careful to use binary mode when " "reading and writing such files." msgstr "" +"Im Textmodus werden beim Lesen standardmäßig plattformspezifische " +"Zeilenenden (``\\n`` unter Unix, ``\\r\\n`` unter Windows) in ``\\n`` " +"umgewandelt. Beim Schreiben im Textmodus werden ``\\n`` standardmäßig wieder" +" in plattformspezifische Zeilenenden umgewandelt. Diese im Hintergrund " +"vorgenommene Änderung der Dateidaten ist für Textdateien unbedenklich, führt" +" jedoch bei Binärdateien wie den in den Formaten :file:`JPEG` oder " +":file:`EXE` zu Datenverlusten. Achte daher unbedingt darauf, beim " +"Lesen und Schreiben solcher Dateien den Binärmodus zu verwenden." msgid "" "It is good practice to use the :keyword:`with` keyword when dealing with " "file objects. The advantage is that the file is properly closed after its " -"suite finishes, even if an exception is raised at some point. Using :" -"keyword:`!with` is also much shorter than writing equivalent :keyword:" -"`try`\\ -\\ :keyword:`finally` blocks::" +"suite finishes, even if an exception is raised at some point. Using " +":keyword:`!with` is also much shorter than writing equivalent " +":keyword:`try`\\ -\\ :keyword:`finally` blocks::" msgstr "" +"Es hat sich bewährt, beim Umgang mit Datei-Objekten das Schlüsselwort " +":keyword:`with` zu verwenden. Der Vorteil besteht darin, dass die Datei " +"nach Abschluss der Suite ordnungsgemäß geschlossen wird, selbst wenn an " +"irgendeiner Stelle eine Ausnahme ausgelöst wird. Die Verwendung von " +":keyword:`!with` ist zudem wesentlich kürzer als das Schreiben der " +"entsprechenden :keyword:`try`\\ -\\ :keyword:`finally`-Blöcke::" msgid "" ">>> with open('workfile', encoding=\"utf-8\") as f:\n" @@ -445,24 +711,40 @@ msgid "" ">>> f.closed\n" "True" msgstr "" +">>> with open('workfile', encoding=\"utf-8\") as f:\n" +"... read_data = f.read()\n" +"\n" +">>> # Wir können überprüfen, ob die Datei automatisch geschlossen wurde.\n" +">>> f.closed\n" +"True" msgid "" -"If you're not using the :keyword:`with` keyword, then you should call ``f." -"close()`` to close the file and immediately free up any system resources " -"used by it." +"If you're not using the :keyword:`with` keyword, then you should call " +"``f.close()`` to close the file and immediately free up any system resources" +" used by it." msgstr "" +"Wenn du das Schlüsselwort :keyword:`with` nicht verwendest, solltest du " +"die Funktion ``f.close()`` aufrufen, um die Datei zu schließen und die " +"von ihr belegten Systemressourcen sofort freizugeben." msgid "" "Calling ``f.write()`` without using the :keyword:`!with` keyword or calling " "``f.close()`` **might** result in the arguments of ``f.write()`` not being " "completely written to the disk, even if the program exits successfully." msgstr "" +"Der Aufruf von ``f.write()`` ohne das Schlüsselwort :keyword:`!with` `" +" oder der Aufruf von ``f.close()`` **kann** dazu führen, dass die " +"Argumente von ``f.write()`` nicht vollständig auf die Festplatte " +"geschrieben werden, selbst wenn das Programm erfolgreich beendet wird." msgid "" "After a file object is closed, either by a :keyword:`with` statement or by " "calling ``f.close()``, attempts to use the file object will automatically " "fail. ::" msgstr "" +"Nachdem ein Dateiobjekt geschlossen wurde – entweder durch eine" +":keyword:`with`-Anweisung oder durch den Aufruf von ``f.close()``– " +"schlagen alle Versuche, das Dateiobjekt zu verwenden, automatisch fehl. ::" msgid "" ">>> f.close()\n" @@ -471,25 +753,42 @@ msgid "" " File \"\", line 1, in \n" "ValueError: I/O operation on closed file." msgstr "" +">>> f.close()\n" +">>> f.read()\n" +"Traceback (letzter Aufruf zuletzt):\n" +" Datei \"\", Zeile 1, in \n" +"ValueError: E/A-Vorgang an einer geschlossenen Datei." msgid "Methods of File Objects" -msgstr "" +msgstr "Methoden von Datei-Objekten" msgid "" "The rest of the examples in this section will assume that a file object " "called ``f`` has already been created." msgstr "" +"In den übrigen Beispielen dieses Abschnitts wird davon ausgegangen, dass " +"bereits ein Dateiobjekt namens ``f`` angelegt wurde." msgid "" "To read a file's contents, call ``f.read(size)``, which reads some quantity " -"of data and returns it as a string (in text mode) or bytes object (in binary " -"mode). *size* is an optional numeric argument. When *size* is omitted or " +"of data and returns it as a string (in text mode) or bytes object (in binary" +" mode). *size* is an optional numeric argument. When *size* is omitted or " "negative, the entire contents of the file will be read and returned; it's " "your problem if the file is twice as large as your machine's memory. " "Otherwise, at most *size* characters (in text mode) or *size* bytes (in " -"binary mode) are read and returned. If the end of the file has been reached, " -"``f.read()`` will return an empty string (``''``). ::" +"binary mode) are read and returned. If the end of the file has been reached," +" ``f.read()`` will return an empty string (``''``). ::" msgstr "" +"Um den Inhalt einer Datei zu lesen, rufe ``f.read(size)``auf. Diese" +" Funktion liest eine bestimmte Datenmenge ein und gibt sie als Zeichenkette " +"(im Textmodus) oder als Byte-Objekt (im Binärmodus) zurück. *size* ist ein " +"optionales numerisches Argument. Wenn *size* weggelassen wird oder negativ " +"ist, wird der gesamte Inhalt der Datei gelesen und zurückgegeben; es ist Ihr" +" Problem, wenn die Datei doppelt so groß ist wie der Arbeitsspeicher Ihres " +"Rechners. Andernfalls werden höchstens *size* Zeichen (im Textmodus) oder " +"*size* Bytes (im Binärmodus) gelesen und zurückgegeben. Wenn das Ende der " +"Datei erreicht wurde, gibt``f.read()`` eine leere Zeichenkette zurück " +"(``''``). ::" msgid "" ">>> f.read()\n" @@ -497,6 +796,10 @@ msgid "" ">>> f.read()\n" "''" msgstr "" +">>> f.read()\n" +"'Das ist der gesamte Inhalt der Datei.\\n'\n" +">>> f.read()\n" +"''" msgid "" "``f.readline()`` reads a single line from the file; a newline character " @@ -506,6 +809,13 @@ msgid "" "end of the file has been reached, while a blank line is represented by " "``'\\n'``, a string containing only a single newline. ::" msgstr "" +"``f.readline()`` Liest eine einzelne Zeile aus der Datei; am Ende der " +"Zeichenkette wird ein Zeilenumbruchzeichen (``\\n``) belassen, das nur in " +"der letzten Zeile der Datei weggelassen wird, wenn die Datei nicht mit einem" +" Zeilenumbruch endet. Dadurch ist der Rückgabewert eindeutig: Wenn " +"``f.readline()`` eine leere Zeichenkette zurückgibt, ist das Ende der " +"Datei erreicht, während eine Leerzeile durch ``'\\n'`` dargestellt wird," +" eine Zeichenkette, die nur ein einziges Zeilenendezeichen enthält. ::" msgid "" ">>> f.readline()\n" @@ -515,11 +825,20 @@ msgid "" ">>> f.readline()\n" "''" msgstr "" +">>> f.readline()\n" +"'Dies ist die erste Zeile der Datei.\\n'\n" +">>> f.readline()\n" +"'Zweite Zeile der Datei\\n'\n" +">>> f.readline()\n" +"''" msgid "" "For reading lines from a file, you can loop over the file object. This is " "memory efficient, fast, and leads to simple code::" msgstr "" +"Um Zeilen aus einer Datei zu lesen, kannst du das Dateiobjekt in einer " +"Schleife durchlaufen. Dies ist speichereffizient, schnell und führt zu " +"einfachem Code::" msgid "" ">>> for line in f:\n" @@ -528,26 +847,39 @@ msgid "" "This is the first line of the file.\n" "Second line of the file" msgstr "" +">>> for line in f:\n" +"... print(line, end='')\n" +"...\n" +"Dies ist die erste Zeile der Datei.\n" +"Zweite Zeile der Datei" msgid "" "If you want to read all the lines of a file in a list you can also use " "``list(f)`` or ``f.readlines()``." msgstr "" +"Wenn du alle Zeilen einer Datei in eine Liste einlesen möchtest, kannst du " +"auch ``list(f)`` oder ``f.readlines()`` verwenden." msgid "" "``f.write(string)`` writes the contents of *string* to the file, returning " "the number of characters written. ::" msgstr "" +"``f.write(string)`` Schreibt den Inhalt von *string* in die Datei und gibt " +"die Anzahl der geschriebenen Zeichen zurück. ::" msgid "" ">>> f.write('This is a test\\n')\n" "15" msgstr "" +">>> f.write('Das ist ein Test\\n')\n" +"15" msgid "" "Other types of objects need to be converted -- either to a string (in text " "mode) or a bytes object (in binary mode) -- before writing them::" msgstr "" +"Andere Objekttypen müssen vor dem Schreiben konvertiert werden – entweder in" +" eine Zeichenkette (im Textmodus) oder in ein Byte-Objekt (im Binärmodus):" msgid "" ">>> value = ('the answer', 42)\n" @@ -555,22 +887,37 @@ msgid "" ">>> f.write(s)\n" "18" msgstr "" +">>> value = ('die Antwort', 42)\n" +">>> s = str(value) # das Tupel in eine Zeichenkette umwandeln\n" +">>> f.write(s)\n" +"18" msgid "" -"``f.tell()`` returns an integer giving the file object's current position in " -"the file represented as number of bytes from the beginning of the file when " -"in binary mode and an opaque number when in text mode." +"``f.tell()`` returns an integer giving the file object's current position in" +" the file represented as number of bytes from the beginning of the file when" +" in binary mode and an opaque number when in text mode." msgstr "" +"``f.tell()`` Gibt eine Ganzzahl zurück, die die aktuelle Position des " +"Dateiobjekts in der Datei angibt – im Binärmodus als Anzahl der Bytes ab dem" +" Dateianfang und im Textmodus als undurchsichtige Zahl." msgid "" "To change the file object's position, use ``f.seek(offset, whence)``. The " "position is computed from adding *offset* to a reference point; the " -"reference point is selected by the *whence* argument. A *whence* value of 0 " -"measures from the beginning of the file, 1 uses the current file position, " +"reference point is selected by the *whence* argument. A *whence* value of 0" +" measures from the beginning of the file, 1 uses the current file position, " "and 2 uses the end of the file as the reference point. *whence* can be " "omitted and defaults to 0, using the beginning of the file as the reference " "point. ::" msgstr "" +"Um die Position des Dateiobjekts zu ändern, verwende``f.seek(offset," +" whence)``. Die Position wird berechnet, indem *offset* zu einem " +"Referenzpunkt addiert wird; der Referenzpunkt wird durch das Argument " +"*whence* festgelegt. Ein *whence*-Wert von 0 misst vom Anfang der Datei " +"aus, 1 verwendet die aktuelle Dateiposition und 2 verwendet das Ende der " +"Datei als Bezugspunkt. *whence* kann weggelassen werden und ist " +"standardmäßig auf 0 gesetzt, wobei der Anfang der Datei als Bezugspunkt " +"verwendet wird. ::" msgid "" ">>> f = open('workfile', 'rb+')\n" @@ -585,23 +932,44 @@ msgid "" ">>> f.read(1)\n" "b'd'" msgstr "" +">>> f = open('workfile', 'rb+')\n" +">>> f.write(b'0123456789abcdef')\n" +"16\n" +">>> f.seek(5) # Zum 6. Byte in der Datei springen\n" +"5\n" +">>> f.read(1)\n" +"b'5'\n" +">>> f.seek(-3, 2) # Zum dritten Byte vor dem Ende springen\n" +"13\n" +">>> f.read(1)\n" +"b'd'" msgid "" "In text files (those opened without a ``b`` in the mode string), only seeks " "relative to the beginning of the file are allowed (the exception being " "seeking to the very file end with ``seek(0, 2)``) and the only valid " -"*offset* values are those returned from the ``f.tell()``, or zero. Any other " -"*offset* value produces undefined behaviour." +"*offset* values are those returned from the ``f.tell()``, or zero. Any other" +" *offset* value produces undefined behaviour." msgstr "" +"In Textdateien (die ohne ``b`` in der Moduszeichenfolge geöffnet wurden)" +" sind nur relative Sprünge zum Dateianfang zulässig (mit Ausnahme des " +"Sprungs zum Dateiende mit ``seek(0, 2)``), und die einzigen gültigen " +"*offset*-Werte sind diejenigen, die von ``f.tell()`` zurückgegeben " +"werden, oder Null. Jeder andere *offset*-Wert führt zu undefiniertem " +"Verhalten." msgid "" -"File objects have some additional methods, such as :meth:`~io.IOBase.isatty` " -"and :meth:`~io.IOBase.truncate` which are less frequently used; consult the " -"Library Reference for a complete guide to file objects." +"File objects have some additional methods, such as :meth:`~io.IOBase.isatty`" +" and :meth:`~io.IOBase.truncate` which are less frequently used; consult the" +" Library Reference for a complete guide to file objects." msgstr "" +"Dateiobjekte verfügen über einige zusätzliche Methoden, wie beispielsweise " +" :meth:`~io.IOBase.isatty` und :meth:`~io.IOBase.truncate`, die jedoch" +" seltener verwendet werden; eine vollständige Anleitung zu Dateiobjekten " +"findest du in der Bibliotheksreferenz." msgid "Saving structured data with :mod:`json`" -msgstr "" +msgstr "Strukturierte Daten speichern mit :mod:`json`" msgid "" "Strings can easily be written to and read from a file. Numbers take a bit " @@ -611,29 +979,53 @@ msgid "" "want to save more complex data types like nested lists and dictionaries, " "parsing and serializing by hand becomes complicated." msgstr "" +"Zeichenketten lassen sich problemlos in eine Datei schreiben und aus einer " +"Datei lesen. Bei Zahlen ist der Aufwand etwas größer, da die Methode" +":meth:`~io.TextIOBase.read` nur Zeichenketten zurückgibt, die an eine " +"Funktion wie:func:`int`übergeben werden müssen, die eine Zeichenkette " +"wie``'123'`` entgegennimmt und deren numerischen Wert 123 zurückgibt. " +"Wenn du komplexere Datentypen wie verschachtelte Listen und Wörterbücher " +"speichern möchtest, wird das manuelle Parsen und Serialisieren kompliziert." msgid "" "Rather than having users constantly writing and debugging code to save " "complicated data types to files, Python allows you to use the popular data " -"interchange format called `JSON (JavaScript Object Notation) `_. The standard module called :mod:`json` can take Python data " -"hierarchies, and convert them to string representations; this process is " -"called :dfn:`serializing`. Reconstructing the data from the string " -"representation is called :dfn:`deserializing`. Between serializing and " -"deserializing, the string representing the object may have been stored in a " -"file or data, or sent over a network connection to some distant machine." -msgstr "" +"interchange format called `JSON (JavaScript Object Notation) " +"`_. The standard module called :mod:`json` can take " +"Python data hierarchies, and convert them to string representations; this " +"process is called :dfn:`serializing`. Reconstructing the data from the " +"string representation is called :dfn:`deserializing`. Between serializing " +"and deserializing, the string representing the object may have been stored " +"in a file or data, or sent over a network connection to some distant " +"machine." +msgstr "" +"Anstatt dass Benutzer ständig Code schreiben und debuggen müssen, um " +"komplizierte Datentypen in Dateien zu speichern, ermöglicht Python die " +"Verwendung des beliebten Datenaustauschformats namens `JSON (JavaScript " +"Object Notation) `_. Das Standardmodul namens :mod:`json`" +" kann Python-Datenhierarchien übernehmen und in Zeichenfolgen-Darstellungen " +"umwandeln; dieser Vorgang wird als :dfn:`Serialisierung` bezeichnet. Das " +"Rekonstruieren der Daten aus der Zeichenfolgenrepräsentation wird als " +":dfn:`Deserialisierung` bezeichnet. Zwischen der Serialisierung und der " +"Deserialisierung kann die das Objekt repräsentierende Zeichenfolge in einer " +"Datei oder einem Datenspeicher abgelegt oder über eine Netzwerkverbindung an" +" einen entfernten Rechner gesendet worden sein." msgid "" "The JSON format is commonly used by modern applications to allow for data " "exchange. Many programmers are already familiar with it, which makes it a " "good choice for interoperability." msgstr "" +"Das JSON-Format wird häufig von modernen Anwendungen für den Datenaustausch " +"verwendet. Viele Programmierer sind bereits damit vertraut, was es zu einer " +"guten Wahl für die Interoperabilität macht." msgid "" "If you have an object ``x``, you can view its JSON string representation " "with a simple line of code::" msgstr "" +"Wenn du ein Objekt vom Typ ``x`` hast, kannst du dessen JSON-" +"Zeichenkettendarstellung mit einer einzigen Codezeile anzeigen::" msgid "" ">>> import json\n" @@ -641,28 +1033,41 @@ msgid "" ">>> json.dumps(x)\n" "'[1, \"simple\", \"list\"]'" msgstr "" +">>> import json\n" +">>> x = [1, 'simple', 'list']\n" +">>> json.dumps(x)\n" +"'[1, \"simple\", \"list\"]'" msgid "" -"Another variant of the :func:`~json.dumps` function, called :func:`~json." -"dump`, simply serializes the object to a :term:`text file`. So if ``f`` is " -"a :term:`text file` object opened for writing, we can do this::" +"Another variant of the :func:`~json.dumps` function, called " +":func:`~json.dump`, simply serializes the object to a :term:`text file`. So" +" if ``f`` is a :term:`text file` object opened for writing, we can do this::" msgstr "" +"Eine weitere Variante der Funktion:func:`~json.dumps`, die den Namen" +":func:`~json.dump`trägt, serialisiert das Objekt einfach in eine " +":term:`Textdatei`. Wenn also ``f`` ein zum Schreiben geöffnetes " +":term:`Textdatei`-Objekt ist, können wir Folgendes tun::" msgid "json.dump(x, f)" -msgstr "" +msgstr "json.dump(x, f)" msgid "" -"To decode the object again, if ``f`` is a :term:`binary file` or :term:`text " -"file` object which has been opened for reading::" +"To decode the object again, if ``f`` is a :term:`binary file` or :term:`text" +" file` object which has been opened for reading::" msgstr "" +"Um das Objekt erneut zu dekodieren, wenn ``f`` ein :term:`Binärdatei`- " +"oder :term:`Textdatei`-Objekt ist, das zum Lesen geöffnet wurde::" msgid "x = json.load(f)" -msgstr "" +msgstr "x = json.load(f)" msgid "" -"JSON files must be encoded in UTF-8. Use ``encoding=\"utf-8\"`` when opening " -"JSON file as a :term:`text file` for both of reading and writing." +"JSON files must be encoded in UTF-8. Use ``encoding=\"utf-8\"`` when opening" +" JSON file as a :term:`text file` for both of reading and writing." msgstr "" +"JSON-Dateien müssen in UTF-8 kodiert sein. Verwende die Option " +"``encoding=\"utf-8\"``, wenn du eine JSON-Datei als :term:`Textdatei` " +"öffnest, sowohl beim Lesen als auch beim Schreiben." msgid "" "This simple serialization technique can handle lists and dictionaries, but " @@ -670,9 +1075,13 @@ msgid "" "effort. The reference for the :mod:`json` module contains an explanation of " "this." msgstr "" +"Diese einfache Serialisierungstechnik eignet sich für Listen und " +"Wörterbücher, doch die Serialisierung beliebiger Klasseninstanzen in JSON " +"erfordert etwas mehr Aufwand. Die Dokumentation zum Modul :mod:`json` " +"enthält eine Erläuterung dazu." msgid ":mod:`pickle` - the pickle module" -msgstr "" +msgstr ":mod:`pickle` - das Pickle-Modul" msgid "" "Contrary to :ref:`JSON `, *pickle* is a protocol which allows the " @@ -682,42 +1091,49 @@ msgid "" "pickle data coming from an untrusted source can execute arbitrary code, if " "the data was crafted by a skilled attacker." msgstr "" +"Im Gegensatz zu :ref:`JSON ` ist *pickle* ein Protokoll, das die " +"Serialisierung beliebig komplexer Python-Objekte ermöglicht. Als solches " +"ist es Python-spezifisch und kann nicht zur Kommunikation mit Anwendungen " +"verwendet werden, die in anderen Sprachen geschrieben sind. Außerdem ist es " +"standardmäßig unsicher: Die Deserialisierung von *pickle*-Daten aus einer " +"nicht vertrauenswürdigen Quelle kann zur Ausführung von beliebigem Code " +"führen, wenn die Daten von einem erfahrenen Angreifer manipuliert wurden." msgid "formatted string literal" -msgstr "" +msgstr "formatiertes String-Literal" msgid "interpolated string literal" -msgstr "" +msgstr "interpoliertes Zeichenfolgenliteral" msgid "string" -msgstr "" +msgstr "Zeichenkette" msgid "formatted literal" -msgstr "" +msgstr "formatiertes Literal" msgid "interpolated literal" -msgstr "" +msgstr "interpoliertes Literal" msgid "f-string" -msgstr "" +msgstr "f-String" msgid "fstring" -msgstr "" +msgstr "fstring" msgid "built-in function" -msgstr "" +msgstr "built-in function" msgid "open" -msgstr "" +msgstr "open" msgid "object" -msgstr "" +msgstr "object" msgid "file" -msgstr "" +msgstr "file" msgid "module" -msgstr "" +msgstr "module" msgid "json" -msgstr "" +msgstr "json" diff --git a/tutorial/modules.po b/tutorial/modules.po index 450025f..54cbec3 100644 --- a/tutorial/modules.po +++ b/tutorial/modules.po @@ -21,27 +21,45 @@ msgstr "" "Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" + msgid "Modules" -msgstr "" +msgstr "Module" msgid "" "If you quit from the Python interpreter and enter it again, the definitions " "you have made (functions and variables) are lost. Therefore, if you want to " "write a somewhat longer program, you are better off using a text editor to " -"prepare the input for the interpreter and running it with that file as input " -"instead. This is known as creating a *script*. As your program gets " -"longer, you may want to split it into several files for easier maintenance. " -"You may also want to use a handy function that you've written in several " +"prepare the input for the interpreter and running it with that file as input" +" instead. This is known as creating a *script*. As your program gets " +"longer, you may want to split it into several files for easier maintenance." +" You may also want to use a handy function that you've written in several " "programs without copying its definition into each program." msgstr "" +"Wenn Sie den Python-Interpreter beenden und erneut starten, gehen die von " +"dir erstellten Definitionen (Funktionen und Variablen) verloren. Wenn du " +"also ein etwas längeres Programm schreiben möchtest, solltest du die Eingabe " +"für den Interpreter besser in einem Texteditor vorbereiten und den " +"Interpreter stattdessen mit dieser Datei als Eingabe ausführen. Dies wird " +"als Erstellen eines *Skripts* bezeichnet. Wenn dein Programm länger wird, " +"möchtes du es möglicherweise zur einfacheren Wartung in mehrere Dateien " +"aufteilen. Vielleicht möchtest du auch eine nützliche Funktion, die du " +"geschrieben hast, in mehreren Programmen verwenden, ohne deren Definition " +"in jedes Programm kopieren zu müssen." msgid "" "To support this, Python has a way to put definitions in a file and use them " -"in a script or in an interactive instance of the interpreter. Such a file is " -"called a *module*; definitions from a module can be *imported* into other " -"modules or into the *main* module (the collection of variables that you have " -"access to in a script executed at the top level and in calculator mode)." +"in a script or in an interactive instance of the interpreter. Such a file is" +" called a *module*; definitions from a module can be *imported* into other " +"modules or into the *main* module (the collection of variables that you have" +" access to in a script executed at the top level and in calculator mode)." msgstr "" +"Um dies zu unterstützen, bietet Python die Möglichkeit, Definitionen in " +"einer Datei zu speichern und sie in einem Skript oder in einer interaktiven " +"Instanz des Interpreters zu verwenden. Eine solche Datei wird als *Modul* " +"bezeichnet; Definitionen aus einem Modul können in andere Module oder in das" +" *Hauptmodul* (*main*) *importiert* werden (die Sammlung von Variablen, auf " +"die du in einem Skript auf oberster Ebene und im Taschenrechnermodus " +"Zugriff hast)." msgid "" "A module is a file containing Python definitions and statements. The file " @@ -51,6 +69,12 @@ msgid "" "to create a file called :file:`fibo.py` in the current directory with the " "following contents::" msgstr "" +"Ein Modul ist eine Datei, die Python-Definitionen und -Anweisungen enthält. " +"Der Dateiname besteht aus dem Modulnamen mit dem angehängten Suffix" +":file:`.py`. Innerhalb eines Moduls steht der Modulname (als " +"Zeichenkette) als Wert der globalen Variablen``__name__`` zur Verfügung." +" Erstelle beispielsweise mit deinem bevorzugten Texteditor im aktuellen" +" Verzeichnis eine Datei namens:file:`fibo.py`mit folgendem Inhalt::" msgid "" "# Fibonacci numbers module\n" @@ -72,14 +96,34 @@ msgid "" " a, b = b, a+b\n" " return result" msgstr "" +"# Modul „Fibonacci-Zahlen“\n" +"\n" +"def fib(n):\n" +" \"\"\"Die Fibonacci-Folge bis n ausgeben.\"\"\"\n" +" a, b = 0, 1\n" +" while a < n:\n" +" print(a, end=' ')\n" +" a, b = b, a+b\n" +" print()\n" +"\n" +"def fib2(n):\n" +" \"\"\"Gibt die Fibonacci-Folge bis n zurück.\"\"\"\n" +" result = []\n" +" a, b = 0, 1\n" +" while a < n:\n" +" result.append(a)\n" +" a, b = b, a+b\n" +" return result" msgid "" "Now enter the Python interpreter and import this module with the following " "command::" msgstr "" +"Öffne nun den Python-Interpreter und importiere dieses Modul mit " +"dem folgenden Befehl::" msgid ">>> import fibo" -msgstr "" +msgstr ">>> import fibo" msgid "" "This does not add the names of the functions defined in ``fibo`` directly " @@ -87,6 +131,10 @@ msgid "" "it only adds the module name ``fibo`` there. Using the module name you can " "access the functions::" msgstr "" +"Dadurch werden die Namen der in ``fibo`` definierten Funktionen nicht direkt" +" zum aktuellen :term:`Namensraum` hinzugefügt (weitere Details finden Sie " +"unter :ref:`tut-scopes` ); es wird dort lediglich der Modulname ``fibo`` " +"hinzugefügt. Über den Modulnamen kannst du auf die Funktionen zugreifen::" msgid "" ">>> fibo.fib(1000)\n" @@ -96,218 +144,341 @@ msgid "" ">>> fibo.__name__\n" "'fibo'" msgstr "" +">>> fibo.fib(1000)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987\n" +">>> fibo.fib2(100)\n" +"[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]\n" +">>> fibo.__name__\n" +"'fibo'" msgid "" "If you intend to use a function often you can assign it to a local name::" msgstr "" +"Wenn du eine Funktion häufig verwenden möchtest, kannst du ihr einen " +"lokalen Namen zuweisen::" msgid "" ">>> fib = fibo.fib\n" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> fib = fibo.fib\n" +">>> fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgid "More on Modules" -msgstr "" +msgstr "Mehr zum Thema Module" msgid "" "A module can contain executable statements as well as function definitions. " "These statements are intended to initialize the module. They are executed " -"only the *first* time the module name is encountered in an import statement. " -"[#]_ (They are also run if the file is executed as a script.)" +"only the *first* time the module name is encountered in an import statement." +" [#]_ (They are also run if the file is executed as a script.)" msgstr "" +"Ein Modul kann sowohl ausführbare Anweisungen als auch Funktionsdefinitionen" +" enthalten. Diese Anweisungen dienen der Initialisierung des Moduls. Sie " +"werden nur beim *ersten* Auftreten des Modulnamens in einer Importanweisung " +"ausgeführt. [#]_ (Sie werden auch ausgeführt, wenn die Datei als Skript " +"ausgeführt wird.)" msgid "" "Each module has its own private namespace, which is used as the global " "namespace by all functions defined in the module. Thus, the author of a " "module can use global variables in the module without worrying about " -"accidental clashes with a user's global variables. On the other hand, if you " -"know what you are doing you can touch a module's global variables with the " +"accidental clashes with a user's global variables. On the other hand, if you" +" know what you are doing you can touch a module's global variables with the " "same notation used to refer to its functions, ``modname.itemname``." msgstr "" +"Jedes Modul verfügt über einen eigenen privaten Namensraum, der von allen im" +" Modul definierten Funktionen als globaler Namensraum genutzt wird. Somit " +"kann der Autor eines Moduls globale Variablen im Modul verwenden, ohne sich " +"Gedanken über versehentliche Konflikte mit den globalen Variablen eines " +"Benutzers machen zu müssen. Andererseits kannst du, wenn du weisst, was " +"du tust, auf die globalen Variablen eines Moduls mit derselben Notation " +"zugreifen, die auch für den Verweis auf dessen Funktionen verwendet wird:" +"``modname.itemname```." msgid "" -"Modules can import other modules. It is customary but not required to place " -"all :keyword:`import` statements at the beginning of a module (or script, " +"Modules can import other modules. It is customary but not required to place" +" all :keyword:`import` statements at the beginning of a module (or script, " "for that matter). The imported module names, if placed at the top level of " "a module (outside any functions or classes), are added to the module's " "global namespace." msgstr "" +"Module können andere Module importieren. Es ist üblich, aber nicht zwingend " +"erforderlich, alle:keyword:`import` `-Anweisungen am Anfang eines Moduls " +"(oder Skripts) zu platzieren. Die Namen der importierten Module werden, " +"sofern sie auf der obersten Ebene eines Moduls (außerhalb von Funktionen " +"oder Klassen) stehen, dem globalen Namensraum des Moduls hinzugefügt." msgid "" "There is a variant of the :keyword:`import` statement that imports names " "from a module directly into the importing module's namespace. For example::" msgstr "" +"Es gibt eine Variante der Anweisung:keyword:`import` , mit der Namen aus" +" einem Modul direkt in den Namensraum des importierenden Moduls importiert " +"werden. Zum Beispiel::" msgid "" ">>> from fibo import fib, fib2\n" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> from fibo import fib, fib2\n" +">>> fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgid "" "This does not introduce the module name from which the imports are taken in " "the local namespace (so in the example, ``fibo`` is not defined)." msgstr "" +"Dadurch wird der Modulname, aus dem die Importe stammen, nicht in den " +"lokalen Namensraum eingeführt (im Beispiel ist``fibo``also nicht " +"definiert)." msgid "There is even a variant to import all names that a module defines::" msgstr "" +"Es gibt sogar eine Variante, mit der alle von einem Modul definierten Namen " +"importiert werden können::" msgid "" ">>> from fibo import *\n" ">>> fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> from fibo import *\n" +">>> fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgid "" -"This imports all names except those beginning with an underscore (``_``). In " -"most cases Python programmers do not use this facility since it introduces " +"This imports all names except those beginning with an underscore (``_``). In" +" most cases Python programmers do not use this facility since it introduces " "an unknown set of names into the interpreter, possibly hiding some things " "you have already defined." msgstr "" +"Dadurch werden alle Namen importiert, mit Ausnahme derjenigen, die mit einem" +" Unterstrich beginnen (``_``). In den meisten Fällen nutzen Python-" +"Programmierer diese Funktion nicht, da dadurch eine unbekannte Menge von " +"Namen in den Interpreter eingeführt wird, wodurch möglicherweise einige " +"bereits von dir definierte Elemente verdeckt werden." msgid "" "Note that in general the practice of importing ``*`` from a module or " "package is frowned upon, since it often causes poorly readable code. " "However, it is okay to use it to save typing in interactive sessions." msgstr "" +"Beachte, dass das Importieren von``*``aus einem Modul oder Paket " +"im Allgemeinen nicht gerne gesehen wird, da dies oft zu schwer lesbarem Code" +" führt. Es ist jedoch in Ordnung, diese Funktion zu verwenden, um sich in " +"interaktiven Sitzungen Tipparbeit zu ersparen." msgid "" -"If the module name is followed by :keyword:`!as`, then the name following :" -"keyword:`!as` is bound directly to the imported module." +"If the module name is followed by :keyword:`!as`, then the name following " +":keyword:`!as` is bound directly to the imported module." msgstr "" +"Folgt auf den Modulnamen:keyword:`!as` “, wird der Name nach" +":keyword:`!as`direkt an das importierte Modul gebunden." msgid "" ">>> import fibo as fib\n" ">>> fib.fib(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> import fibo as fib\n" +">>> fib.fib(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgid "" "This is effectively importing the module in the same way that ``import " "fibo`` will do, with the only difference of it being available as ``fib``." msgstr "" +"Damit wird das Modul im Grunde genauso importiert wie mit dem Befehl" +"``import fibo`` “, mit dem einzigen Unterschied, dass es unter``fib``" +"verfügbar ist." msgid "" "It can also be used when utilising :keyword:`from` with similar effects::" msgstr "" +"Es kann auch bei der Verwendung von :keyword:`from` mit ähnlichen " +"Effekten eingesetzt werden::" msgid "" ">>> from fibo import fib as fibonacci\n" ">>> fibonacci(500)\n" "0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgstr "" +">>> from fibo import fib as fibonacci\n" +">>> fibonacci(500)\n" +"0 1 1 2 3 5 8 13 21 34 55 89 144 233 377" msgid "" "For efficiency reasons, each module is only imported once per interpreter " "session. Therefore, if you change your modules, you must restart the " "interpreter -- or, if it's just one module you want to test interactively, " -"use :func:`importlib.reload`, e.g. ``import importlib; importlib." -"reload(modulename)``." +"use :func:`importlib.reload`, e.g. ``import importlib; " +"importlib.reload(modulename)``." msgstr "" +"Aus Effizienzgründen wird jedes Modul pro Interpreter-Sitzung nur einmal " +"geladen. Wenn du also Ihre Module änderst, musst du den Interpreter neu " +"starten – oder, falls du nur ein Modul interaktiv testen möchten, die " +"Funktion:func:`importlib.reload`verwenden, z. B. ``import importlib; " +"importlib.reload(modulename)``." msgid "Executing modules as scripts" -msgstr "" +msgstr "Module als Skripte ausführen" msgid "When you run a Python module with ::" -msgstr "" +msgstr "Wenn du ein Python-Modul mit :: ausführst:" msgid "python fibo.py " -msgstr "" +msgstr "python fibo.py " msgid "" "the code in the module will be executed, just as if you imported it, but " "with the ``__name__`` set to ``\"__main__\"``. That means that by adding " "this code at the end of your module::" msgstr "" +"Der Code im Modul wird ausgeführt, genau so, als hättest du ihn importiert, " +"allerdings mit der Einstellung ``__name__``auf ``\"__main__\"`` . " +"Das bedeutet, dass du durch Hinzufügen dieses Codes am Ende deines Moduls::" msgid "" "if __name__ == \"__main__\":\n" " import sys\n" " fib(int(sys.argv[1]))" msgstr "" +"if __name__ == \"__main__\":\n" +" import sys\n" +" fib(int(sys.argv[1]))" msgid "" "you can make the file usable as a script as well as an importable module, " "because the code that parses the command line only runs if the module is " "executed as the \"main\" file:" msgstr "" +"Du kannst die Datei sowohl als Skript als auch als importierbares Modul " +"nutzen, da der Code, der die Befehlszeile auswertet, nur ausgeführt wird, " +"wenn das Modul als \"Hauptdatei\“ ausgeführt wird:" msgid "" "$ python fibo.py 50\n" "0 1 1 2 3 5 8 13 21 34" msgstr "" +"$ python fibo.py 50\n" +"0 1 1 2 3 5 8 13 21 34" msgid "If the module is imported, the code is not run::" -msgstr "" +msgstr "Wenn das Modul importiert wird, wird der Code nicht ausgeführt::" msgid "" ">>> import fibo\n" ">>>" msgstr "" +">>> import fibo\n" +">>>" msgid "" "This is often used either to provide a convenient user interface to a " "module, or for testing purposes (running the module as a script executes a " "test suite)." msgstr "" +"Dies wird häufig entweder verwendet, um eine benutzerfreundliche Oberfläche " +"für ein Modul bereitzustellen, oder zu Testzwecken (die Ausführung des " +"Moduls als Skript führt eine Testsuite aus)." msgid "The Module Search Path" -msgstr "" +msgstr "Der Suchpfad für Module" msgid "" -"When a module named :mod:`!spam` is imported, the interpreter first searches " -"for a built-in module with that name. These module names are listed in :data:" -"`sys.builtin_module_names`. If not found, it then searches for a file named :" -"file:`spam.py` in a list of directories given by the variable :data:`sys." -"path`. :data:`sys.path` is initialized from these locations:" +"When a module named :mod:`!spam` is imported, the interpreter first searches" +" for a built-in module with that name. These module names are listed in " +":data:`sys.builtin_module_names`. If not found, it then searches for a file " +"named :file:`spam.py` in a list of directories given by the variable " +":data:`sys.path`. :data:`sys.path` is initialized from these locations:" msgstr "" +"Wenn ein Modul namens :mod:`!spam` importiert wird, sucht der " +"Interpreter zunächst nach einem integrierten Modul mit diesem Namen. Diese " +"Modulnamen sind unter :data:`sys.builtin_module_names` aufgeführt. Wird es " +"dort nicht gefunden, sucht er anschließend nach einer Datei namens" +":file:`spam.py` in einer Liste von Verzeichnissen, die durch die Variable " +" :data:`sys.path`angegeben wird. :data:`sys.path`wird anhand dieser" +" Speicherorte initialisiert:" msgid "" "The directory containing the input script (or the current directory when no " "file is specified)." msgstr "" +"Das Verzeichnis, in dem sich das Eingabeskript befindet (oder das aktuelle " +"Verzeichnis, wenn keine Datei angegeben ist)." msgid "" -":envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the " -"shell variable :envvar:`PATH`)." +":envvar:`PYTHONPATH` (a list of directory names, with the same syntax as the" +" shell variable :envvar:`PATH`)." msgstr "" +":envvar:`PYTHONPATH` (eine Liste von Verzeichnisnamen, deren Syntax der der " +"Shell-Variablen :envvar:`PATH`entspricht)." msgid "" "The installation-dependent default (by convention including a ``site-" "packages`` directory, handled by the :mod:`site` module)." msgstr "" +"Die installationsabhängige Standardeinstellung (gemäß Konvention " +"einschließlich des Verzeichnisses ``site-packages`` , das vom Modul" +" :mod:`site`verwaltet wird)." msgid "More details are at :ref:`sys-path-init`." -msgstr "" +msgstr "Weitere Informationen findest du unter :ref:`sys-path-init`." msgid "" "On file systems which support symlinks, the directory containing the input " "script is calculated after the symlink is followed. In other words the " "directory containing the symlink is **not** added to the module search path." msgstr "" +"Bei Dateisystemen, die symbolische Links unterstützen, wird das Verzeichnis," +" in dem sich das Eingabeskript befindet, erst ermittelt, nachdem dem " +"symbolischen Link gefolgt wurde. Mit anderen Worten: Das Verzeichnis, in dem" +" sich der symbolische Link befindet, wird **nicht** zum Suchpfad des Moduls " +"hinzugefügt." msgid "" "After initialization, Python programs can modify :data:`sys.path`. The " "directory containing the script being run is placed at the beginning of the " "search path, ahead of the standard library path. This means that scripts in " "that directory will be loaded instead of modules of the same name in the " -"library directory. This is an error unless the replacement is intended. See " -"section :ref:`tut-standardmodules` for more information." -msgstr "" +"library directory. This is an error unless the replacement is intended. See" +" section :ref:`tut-standardmodules` for more information." +msgstr "" +"Nach der Initialisierung können Python-Programme die Variable" +" :data:`sys.path` ändern. Das Verzeichnis, in dem sich das ausgeführte " +"Skript befindet, wird an den Anfang des Suchpfads gesetzt, noch vor dem " +"Standardbibliothekspfad. Das bedeutet, dass Skripte in diesem Verzeichnis " +"anstelle von Modulen mit demselben Namen im Bibliotheksverzeichnis geladen " +"werden. Dies führt zu einem Fehler, es sei denn, die Ersetzung ist " +"beabsichtigt. Weitere Informationen findest du im Abschnitt :ref:`tut-" +"standardmodules` ." msgid "\"Compiled\" Python files" -msgstr "" +msgstr "\"Kompilierte\“ Python-Dateien" msgid "" "To speed up loading modules, Python caches the compiled version of each " -"module in the ``__pycache__`` directory under the name :file:`module." -"{version}.pyc`, where the version encodes the format of the compiled file; " -"it generally contains the Python version number. For example, in CPython " -"release 3.3 the compiled version of spam.py would be cached as ``__pycache__/" -"spam.cpython-33.pyc``. This naming convention allows compiled modules from " -"different releases and different versions of Python to coexist." -msgstr "" +"module in the ``__pycache__`` directory under the name " +":file:`module.{version}.pyc`, where the version encodes the format of the " +"compiled file; it generally contains the Python version number. For " +"example, in CPython release 3.3 the compiled version of spam.py would be " +"cached as ``__pycache__/spam.cpython-33.pyc``. This naming convention " +"allows compiled modules from different releases and different versions of " +"Python to coexist." +msgstr "" +"Um das Laden von Modulen zu beschleunigen, speichert Python die kompilierte " +"Version jedes Moduls im Verzeichnis ``__pycache__`` unter dem Namen " +":file:`module.{version}.pyc` , wobei die Versionsangabe das Format der " +"kompilierten Datei angibt; sie enthält in der Regel die Python-" +"Versionsnummer. Beispielsweise würde in der CPython-Version 3.3 die " +"kompilierte Version von spam.py als ``__pycache__/spam.cpython-33.pyc`` " +"zwischengespeichert werden. Diese Namenskonvention ermöglicht es, dass " +"kompilierte Module aus verschiedenen Releases und verschiedenen Python-" +"Versionen nebeneinander existieren können." msgid "" "Python checks the modification date of the source against the compiled " @@ -316,47 +487,75 @@ msgid "" "independent, so the same library can be shared among systems with different " "architectures." msgstr "" +"Python vergleicht das Änderungsdatum der Quelldatei mit der kompilierten " +"Version, um festzustellen, ob diese veraltet ist und neu kompiliert werden " +"muss. Dies ist ein vollständig automatischer Vorgang. Außerdem sind die " +"kompilierten Module plattformunabhängig, sodass dieselbe Bibliothek auf " +"Systemen mit unterschiedlichen Architekturen gemeinsam genutzt werden kann." msgid "" "Python does not check the cache in two circumstances. First, it always " "recompiles and does not store the result for the module that's loaded " "directly from the command line. Second, it does not check the cache if " "there is no source module. To support a non-source (compiled only) " -"distribution, the compiled module must be in the source directory, and there " -"must not be a source module." +"distribution, the compiled module must be in the source directory, and there" +" must not be a source module." msgstr "" +"Python überprüft den Cache unter zwei Umständen nicht. Erstens wird das " +"Modul, das direkt über die Befehlszeile geladen wird, immer neu kompiliert, " +"und das Ergebnis wird nicht gespeichert. Zweitens wird der Cache nicht " +"überprüft, wenn kein Quellmodul vorhanden ist. Um eine Distribution ohne " +"Quellcode (nur kompiliert) zu unterstützen, muss sich das kompilierte Modul " +"im Quellverzeichnis befinden, und es darf kein Quellmodul vorhanden sein." msgid "Some tips for experts:" -msgstr "" +msgstr "Einige Tipps für Experten:" msgid "" -"You can use the :option:`-O` or :option:`-OO` switches on the Python command " -"to reduce the size of a compiled module. The ``-O`` switch removes assert " +"You can use the :option:`-O` or :option:`-OO` switches on the Python command" +" to reduce the size of a compiled module. The ``-O`` switch removes assert " "statements, the ``-OO`` switch removes both assert statements and __doc__ " -"strings. Since some programs may rely on having these available, you should " -"only use this option if you know what you're doing. \"Optimized\" modules " +"strings. Since some programs may rely on having these available, you should" +" only use this option if you know what you're doing. \"Optimized\" modules " "have an ``opt-`` tag and are usually smaller. Future releases may change " "the effects of optimization." msgstr "" +"Sie können die Schalter :option:`-O`oder :option:`-OO`im Python-" +"Befehl verwenden, um die Größe eines kompilierten Moduls zu verringern. Der " +"Schalter ``-O`` entfernt \"assert\“-Anweisungen, der Schalter ``-OO`` " +"entfernt sowohl \"assert\“-Anweisungen als auch \"__doc__\“-Zeichenketten. Da " +"manche Programme möglicherweise darauf angewiesen sind, dass diese verfügbar" +" sind, solltest du diese Option nur verwenden, wenn du genau weisst, was " +"du tust. \"Optimierte\“ Module tragen das Tag ``opt-`` und sind in der " +"Regel kleiner. In zukünftigen Versionen können sich die Auswirkungen der " +"Optimierung ändern." msgid "" "A program doesn't run any faster when it is read from a ``.pyc`` file than " -"when it is read from a ``.py`` file; the only thing that's faster about ``." -"pyc`` files is the speed with which they are loaded." +"when it is read from a ``.py`` file; the only thing that's faster about " +"``.pyc`` files is the speed with which they are loaded." msgstr "" +"Ein Programm läuft nicht schneller, wenn es aus einer ``.pyc`` -Datei " +"geladen wird, als wenn es aus einer ``.py`` -Datei geladen wird; das " +"Einzige, was bei ``.pyc`` -Dateien schneller ist, ist die Geschwindigkeit, " +"mit der sie geladen werden." msgid "" "The module :mod:`compileall` can create .pyc files for all modules in a " "directory." msgstr "" +"Das Modul :mod:`compileall` kann für alle Module in einem Verzeichnis " +".pyc-Dateien erstellen." msgid "" "There is more detail on this process, including a flow chart of the " "decisions, in :pep:`3147`." msgstr "" +"Weitere Einzelheiten zu diesem Prozess, einschließlich eines " +"Entscheidungsdiagramms, findest du unter :pep:`3147`." msgid "Standard Modules" -msgstr "" +msgstr "Standardmodule" msgid "" "Python comes with a library of standard modules, described in a separate " @@ -371,6 +570,19 @@ msgid "" "into every Python interpreter. The variables ``sys.ps1`` and ``sys.ps2`` " "define the strings used as primary and secondary prompts::" msgstr "" +"Python verfügt über eine Bibliothek mit Standardmodulen, die in einem " +"separaten Dokument, der Python-Bibliotheksreferenz (im Folgenden " +"\"Bibliotheksreferenz\“), beschrieben sind. Einige Module sind in den " +"Interpreter integriert; diese bieten Zugriff auf Operationen, die zwar nicht" +" zum Kern der Sprache gehören, aber dennoch integriert sind – entweder aus " +"Gründen der Effizienz oder um Zugriff auf Betriebssystemprimitive wie " +"Systemaufrufe zu ermöglichen. Die Auswahl dieser Module ist eine " +"Konfigurationsoption, die zudem von der zugrunde liegenden Plattform " +"abhängt. Beispielsweise wird das Modul :mod:`winreg` nur auf Windows-" +"Systemen bereitgestellt. Ein bestimmtes Modul verdient besondere Beachtung: " +" :mod:`sys` , das in jeden Python-Interpreter integriert ist. Die " +"Variablen ``sys.ps1`` und ``sys.ps2`` definieren die Zeichenketten, " +"die als primäre und sekundäre Eingabeaufforderung verwendet werden::" msgid "" ">>> import sys\n" @@ -383,32 +595,54 @@ msgid "" "Yuck!\n" "C>" msgstr "" +">>> import sys\n" +">>> sys.ps1\n" +"'>>> '\n" +">>> sys.ps2\n" +"'... '\n" +">>> sys.ps1 = 'C> '\n" +"C> print('Igitt!')\n" +"Igitt!\n" +"C>" msgid "" "These two variables are only defined if the interpreter is in interactive " "mode." msgstr "" +"Diese beiden Variablen sind nur definiert, wenn sich der Interpreter im " +"interaktiven Modus befindet." msgid "" "The variable ``sys.path`` is a list of strings that determines the " "interpreter's search path for modules. It is initialized to a default path " -"taken from the environment variable :envvar:`PYTHONPATH`, or from a built-in " -"default if :envvar:`PYTHONPATH` is not set. You can modify it using " +"taken from the environment variable :envvar:`PYTHONPATH`, or from a built-in" +" default if :envvar:`PYTHONPATH` is not set. You can modify it using " "standard list operations::" msgstr "" +"Die Variable ``sys.path`` ist eine Liste von Zeichenketten, die den " +"Suchpfad des Interpreters für Module festlegt. Sie wird mit einem " +"Standardpfad initialisiert, der aus der Umgebungsvariable " +":envvar:`PYTHONPATH` übernommen wird, oder – falls :envvar:`PYTHONPATH` " +" nicht gesetzt ist – mit einem integrierten Standardwert. Sie können sie " +"mithilfe von Standardoperationen für Listen ändern::" msgid "" ">>> import sys\n" ">>> sys.path.append('/ufs/guido/lib/python')" msgstr "" +">>> import sys\n" +">>> sys.path.append('/ufs/guido/lib/python')" msgid "The :func:`dir` Function" -msgstr "" +msgstr "Die Funktion :func:`dir` " msgid "" "The built-in function :func:`dir` is used to find out which names a module " "defines. It returns a sorted list of strings::" msgstr "" +"Die integrierte Funktion :func:`dir` dient dazu, herauszufinden, welche " +"Namen ein Modul definiert. Sie gibt eine sortierte Liste von Zeichenketten " +"zurück::" msgid "" ">>> import fibo, sys\n" @@ -416,38 +650,58 @@ msgid "" "['__name__', 'fib', 'fib2']\n" ">>> dir(sys)\n" "['__breakpointhook__', '__displayhook__', '__doc__', '__excepthook__',\n" -" '__interactivehook__', '__loader__', '__name__', '__package__', " -"'__spec__',\n" +" '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__',\n" " '__stderr__', '__stdin__', '__stdout__', '__unraisablehook__',\n" " '_clear_type_cache', '_current_frames', '_debugmallocstats', '_framework',\n" " '_getframe', '_git', '_home', '_xoptions', 'abiflags', 'addaudithook',\n" " 'api_version', 'argv', 'audit', 'base_exec_prefix', 'base_prefix',\n" " 'breakpointhook', 'builtin_module_names', 'byteorder', 'call_tracing',\n" -" 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', " -"'exc_info',\n" +" 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info',\n" " 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info',\n" -" 'float_repr_style', 'get_asyncgen_hooks', " -"'get_coroutine_origin_tracking_depth',\n" +" 'float_repr_style', 'get_asyncgen_hooks', 'get_coroutine_origin_tracking_depth',\n" " 'getallocatedblocks', 'getdefaultencoding', 'getdlopenflags',\n" " 'getfilesystemencodeerrors', 'getfilesystemencoding', 'getprofile',\n" " 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval',\n" " 'gettrace', 'hash_info', 'hexversion', 'implementation', 'int_info',\n" " 'intern', 'is_finalizing', 'last_traceback', 'last_type', 'last_value',\n" " 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks',\n" -" 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', " -"'pycache_prefix',\n" -" 'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', " -"'setdlopenflags',\n" -" 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', " -"'stderr',\n" -" 'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', " -"'version_info',\n" +" 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'pycache_prefix',\n" +" 'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', 'setdlopenflags',\n" +" 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr',\n" +" 'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', 'version_info',\n" " 'warnoptions']" msgstr "" +">>> import fibo, sys\n" +">>> dir(fibo)\n" +"['__name__', 'fib', 'fib2']\n" +">>> dir(sys)\n" +"['__breakpointhook__', '__displayhook__', '__doc__', '__excepthook__',\n" +" '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__',\n" +" '__stderr__', '__stdin__', '__stdout__', '__unraisablehook__',\n" +" '_clear_type_cache', '_current_frames', '_debugmallocstats', '_framework',\n" +" '_getframe', '_git', '_home', '_xoptions', 'abiflags', 'addaudithook',\n" +" 'api_version', 'argv', 'audit', 'base_exec_prefix', 'base_prefix',\n" +" 'breakpointhook', 'builtin_module_names', 'byteorder', 'call_tracing',\n" +" 'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info',\n" +" 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info',\n" +" 'float_repr_style', 'get_asyncgen_hooks', 'get_coroutine_origin_tracking_depth',\n" +" 'getallocatedblocks', 'getdefaultencoding', 'getdlopenflags',\n" +" 'getfilesystemencodeerrors', 'getfilesystemencoding', 'getprofile',\n" +" 'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval',\n" +" 'gettrace', 'hash_info', 'hexversion', 'implementation', 'int_info',\n" +" 'intern', 'is_finalizing', 'last_traceback', 'last_type', 'last_value',\n" +" 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks',\n" +" 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'pycache_prefix',\n" +" 'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', 'setdlopenflags',\n" +" 'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr',\n" +" 'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', 'version_info',\n" +" 'warnoptions']" msgid "" "Without arguments, :func:`dir` lists the names you have defined currently::" msgstr "" +"Ohne Argumente listet der Befehl :func:`dir` die Namen auf, die du " +"derzeit definiert hast::" msgid "" ">>> a = [1, 2, 3, 4, 5]\n" @@ -456,16 +710,26 @@ msgid "" ">>> dir()\n" "['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']" msgstr "" +">>> a = [1, 2, 3, 4, 5]\n" +">>> import fibo\n" +">>> fib = fibo.fib\n" +">>> dir()\n" +"['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']" msgid "" "Note that it lists all types of names: variables, modules, functions, etc." msgstr "" +"Beachte, dass hier alle Arten von Namen aufgeführt sind: Variablen, " +"Module, Funktionen usw." msgid "" -":func:`dir` does not list the names of built-in functions and variables. If " -"you want a list of those, they are defined in the standard module :mod:" -"`builtins`::" +":func:`dir` does not list the names of built-in functions and variables. If" +" you want a list of those, they are defined in the standard module " +":mod:`builtins`::" msgstr "" +":func:`dir` enthält keine Auflistung der Namen der integrierten Funktionen " +"und Variablen. Wenn du eine Liste davon benötigst: Diese sind im " +"Standardmodul :mod:`builtins` definiert ::" msgid "" ">>> import builtins\n" @@ -479,8 +743,7 @@ msgid "" " 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',\n" " 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError',\n" " 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError',\n" -" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', " -"'NotImplemented',\n" +" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented',\n" " 'NotImplementedError', 'OSError', 'OverflowError',\n" " 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError',\n" " 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning',\n" @@ -501,9 +764,40 @@ msgid "" " 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars',\n" " 'zip']" msgstr "" +">>> import builtins\n" +">>> dir(builtins)\n" +"['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException',\n" +" 'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning',\n" +" 'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError',\n" +" 'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning',\n" +" 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False',\n" +" 'FileExistsError', 'FileNotFoundError', 'FloatingPointError',\n" +" 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',\n" +" 'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError',\n" +" 'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError',\n" +" 'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented',\n" +" 'NotImplementedError', 'OSError', 'OverflowError',\n" +" 'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError',\n" +" 'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning',\n" +" 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',\n" +" 'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError',\n" +" 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError',\n" +" 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning',\n" +" 'ValueError', 'Warning', 'ZeroDivisionError', '_', '__build_class__',\n" +" '__debug__', '__doc__', '__import__', '__name__', '__package__', 'abs',\n" +" 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable',\n" +" 'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits',\n" +" 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit',\n" +" 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr',\n" +" 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass',\n" +" 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview',\n" +" 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property',\n" +" 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',\n" +" 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars',\n" +" 'zip']" msgid "Packages" -msgstr "" +msgstr "Pakete" msgid "" "Packages are a way of structuring Python's module namespace by using " @@ -514,12 +808,20 @@ msgid "" "saves the authors of multi-module packages like NumPy or Pillow from having " "to worry about each other's module names." msgstr "" +"Pakete sind eine Möglichkeit, den Modul-Namensraum von Python mithilfe von " +"\"Modulnamen mit Punkt\“ zu strukturieren. Der Modulname :mod:`!A.B` " +"bezeichnet beispielsweise ein Untermodul namens ``B`` in einem Paket " +"namens ``A`` . Genauso wie die Verwendung von Modulen den Autoren " +"verschiedener Module erspart, sich um die globalen Variablennamen der " +"anderen kümmern zu müssen, erspart die Verwendung von Modulnamen mit Punkten" +" den Autoren von Paketen mit mehreren Modulen wie NumPy oder Pillow, sich um" +" die Modulnamen der anderen kümmern zu müssen." msgid "" "Suppose you want to design a collection of modules (a \"package\") for the " "uniform handling of sound files and sound data. There are many different " -"sound file formats (usually recognized by their extension, for example: :" -"file:`.wav`, :file:`.aiff`, :file:`.au`), so you may need to create and " +"sound file formats (usually recognized by their extension, for example: " +":file:`.wav`, :file:`.aiff`, :file:`.au`), so you may need to create and " "maintain a growing collection of modules for the conversion between the " "various file formats. There are also many different operations you might " "want to perform on sound data (such as mixing, adding echo, applying an " @@ -528,6 +830,18 @@ msgid "" "operations. Here's a possible structure for your package (expressed in " "terms of a hierarchical filesystem):" msgstr "" +"Angenommen, du möchtest eine Sammlung von Modulen (ein „Paket“) für die " +"einheitliche Verarbeitung von Audiodateien und Audiodaten entwerfen. Es gibt" +" viele verschiedene Audiodateiformate (die in der Regel an ihrer Dateiendung" +" zu erkennen sind, zum Beispiel: :file:`.wav`, :file:`.aiff`, :file:`.au`), " +"sodass du möglicherweise eine ständig wachsende Sammlung von Modulen für " +"die Konvertierung zwischen den verschiedenen Dateiformaten erstellen und " +"pflegen musst. Außerdem gibt es viele verschiedene Operationen, die du " +"möglicherweise an Audiodaten durchführen möchtest (wie Mischen, Hinzufügen " +"eines Echos, Anwenden einer Equalizer-Funktion, Erzeugen eines künstlichen " +"Stereoeffekts), sodass du darüber hinaus eine endlose Reihe von Modulen " +"schreiben wirst, um diese Operationen auszuführen. Hier ist eine mögliche " +"Struktur für dein Paket (dargestellt als hierarchisches Dateisystem):" msgid "" "sound/ Top-level package\n" @@ -554,86 +868,144 @@ msgid "" " karaoke.py\n" " ..." msgstr "" +"sound/ Paket der obersten Ebene\n" +" __init__.py Initialisierung des Sound-Pakets\n" +" formats/ Unterpaket für Dateiformatkonvertierungen\n" +" __init__.py\n" +" wavread.py\n" +" wavwrite.py\n" +" aiffread.py\n" +" aiffwrite.py\n" +" auread.py\n" +" auwrite.py\n" +" ...\n" +" effects/ Unterpaket für Soundeffekte\n" +" __init__.py\n" +" echo.py\n" +" surround.py\n" +" reverse.py\n" +" ...\n" +" filters/ Unterpaket für Filter\n" +" __init__.py\n" +" equalizer.py\n" +" vocoder.py\n" +" karaoke.py\n" +" ..." msgid "" -"When importing the package, Python searches through the directories on ``sys." -"path`` looking for the package subdirectory." +"When importing the package, Python searches through the directories on " +"``sys.path`` looking for the package subdirectory." msgstr "" +"Beim Importieren des Pakets durchsucht Python die Verzeichnisse unter " +"``sys.path`` nach dem Unterverzeichnis des Pakets." msgid "" "The :file:`__init__.py` files are required to make Python treat directories " -"containing the file as packages (unless using a :term:`namespace package`, a " -"relatively advanced feature). This prevents directories with a common name, " -"such as ``string``, from unintentionally hiding valid modules that occur " +"containing the file as packages (unless using a :term:`namespace package`, a" +" relatively advanced feature). This prevents directories with a common name," +" such as ``string``, from unintentionally hiding valid modules that occur " "later on the module search path. In the simplest case, :file:`__init__.py` " "can just be an empty file, but it can also execute initialization code for " "the package or set the ``__all__`` variable, described later." msgstr "" +"Die :file:`__init__.py` -Dateien sind erforderlich, damit Python " +"Verzeichnisse, die diese Datei enthalten, als Pakete behandelt (es sei denn," +" es wird ein :term:`Namespace-Paket` verwendet, eine relativ " +"fortgeschrittene Funktion). Dies verhindert, dass Verzeichnisse mit einem " +"gemeinsamen Namen, wie beispielsweise ``string`` , unbeabsichtigt gültige" +" Module verdecken, die später im Modulsuchpfad vorkommen. Im einfachsten " +"Fall kann :file:`__init__.py` einfach eine leere Datei sein, sie kann " +"aber auch Initialisierungscode für das Paket ausführen oder die Variable " +"``__all__`` setzen, die später beschrieben wird." msgid "" "Users of the package can import individual modules from the package, for " "example::" msgstr "" +"Benutzer des Pakets können einzelne Module aus dem Paket importieren, zum " +"Beispiel::" msgid "import sound.effects.echo" -msgstr "" +msgstr "import sound.effects.echo" msgid "" "This loads the submodule :mod:`!sound.effects.echo`. It must be referenced " "with its full name. ::" msgstr "" +"Dadurch wird das Submodul :mod:`!sound.effects.echo` geladen. Es muss " +"mit seinem vollständigen Namen referenziert werden. ::" msgid "sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)" -msgstr "" +msgstr "sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)" msgid "An alternative way of importing the submodule is::" -msgstr "" +msgstr "Eine alternative Möglichkeit, das Submodul zu importieren, ist:" msgid "from sound.effects import echo" -msgstr "" +msgstr "from sound.effects import echo" msgid "" "This also loads the submodule :mod:`!echo`, and makes it available without " "its package prefix, so it can be used as follows::" msgstr "" +"Dadurch wird auch das Submodul :mod:`!echo` geladen und ohne sein " +"Paketpräfix zur Verfügung gestellt, sodass es wie folgt verwendet werden " +"kann::" msgid "echo.echofilter(input, output, delay=0.7, atten=4)" -msgstr "" +msgstr "echo.echofilter(input, output, delay=0.7, atten=4)" msgid "" "Yet another variation is to import the desired function or variable " "directly::" msgstr "" +"Eine weitere Möglichkeit besteht darin, die gewünschte Funktion oder " +"Variable direkt zu importieren::" msgid "from sound.effects.echo import echofilter" -msgstr "" +msgstr "from sound.effects.echo import echofilter" msgid "" -"Again, this loads the submodule :mod:`!echo`, but this makes its function :" -"func:`!echofilter` directly available::" +"Again, this loads the submodule :mod:`!echo`, but this makes its function " +":func:`!echofilter` directly available::" msgstr "" +"Auch hier wird das Submodul :mod:`!echo` geladen, wodurch dessen " +"Funktion :func:`!echofilter` direkt verfügbar ist::" msgid "echofilter(input, output, delay=0.7, atten=4)" -msgstr "" +msgstr "echofilter(input, output, delay=0.7, atten=4)" msgid "" "Note that when using ``from package import item``, the item can be either a " -"submodule (or subpackage) of the package, or some other name defined in the " -"package, like a function, class or variable. The ``import`` statement first " -"tests whether the item is defined in the package; if not, it assumes it is a " -"module and attempts to load it. If it fails to find it, an :exc:" -"`ImportError` exception is raised." -msgstr "" +"submodule (or subpackage) of the package, or some other name defined in the" +" package, like a function, class or variable. The ``import`` statement " +"first tests whether the item is defined in the package; if not, it assumes " +"it is a module and attempts to load it. If it fails to find it, an " +":exc:`ImportError` exception is raised." +msgstr "" +"Beachte dass bei der Verwendung von ``from package import item`` das " +"Element entweder ein Submodul (oder Subpaket) des Pakets oder ein anderer im" +" Paket definierter Name sein kann, wie beispielsweise eine Funktion, eine " +"Klasse oder eine Variable. Die Anweisung ``import`` prüft zunächst, ob " +"das Element im Paket definiert ist; ist dies nicht der Fall, geht sie davon " +"aus, dass es sich um ein Modul handelt, und versucht, dieses zu laden. Wird" +" das Element nicht gefunden, wird eine Ausnahme vom Typ :exc:`ImportError` " +"ausgelöst." msgid "" "Contrarily, when using syntax like ``import item.subitem.subsubitem``, each " -"item except for the last must be a package; the last item can be a module or " -"a package but can't be a class or function or variable defined in the " +"item except for the last must be a package; the last item can be a module or" +" a package but can't be a class or function or variable defined in the " "previous item." msgstr "" +"Im Gegensatz dazu muss bei der Verwendung einer Syntax wie ``import " +"item.subitem.subsubitem`` jedes Element mit Ausnahme des letzten ein Paket" +" sein; das letzte Element kann ein Modul oder ein Paket sein, darf jedoch " +"keine Klasse, Funktion oder Variable sein, die im vorherigen Element " +"definiert wurde." msgid "Importing \\* From a Package" -msgstr "" +msgstr "Importieren von \\* aus einem Paket" msgid "" "Now what happens when the user writes ``from sound.effects import *``? " @@ -642,35 +1014,61 @@ msgid "" "could take a long time and importing sub-modules might have unwanted side-" "effects that should only happen when the sub-module is explicitly imported." msgstr "" +"Was passiert nun, wenn der Benutzer ``from sound.effects import *`` " +"eingibt? Im Idealfall würde man hoffen, dass dies irgendwie an das " +"Dateisystem weitergeleitet wird, das dann ermittelt, welche Submodule im " +"Paket vorhanden sind, und diese alle importiert. Dies könnte lange dauern, " +"und das Importieren von Submodulen könnte unerwünschte Nebenwirkungen haben," +" die nur auftreten sollten, wenn das Submodul explizit importiert wird." msgid "" "The only solution is for the package author to provide an explicit index of " -"the package. The :keyword:`import` statement uses the following convention: " -"if a package's :file:`__init__.py` code defines a list named ``__all__``, it " -"is taken to be the list of module names that should be imported when ``from " -"package import *`` is encountered. It is up to the package author to keep " -"this list up-to-date when a new version of the package is released. Package " -"authors may also decide not to support it, if they don't see a use for " -"importing \\* from their package. For example, the file :file:`sound/" -"effects/__init__.py` could contain the following code::" -msgstr "" +"the package. The :keyword:`import` statement uses the following convention:" +" if a package's :file:`__init__.py` code defines a list named ``__all__``, " +"it is taken to be the list of module names that should be imported when " +"``from package import *`` is encountered. It is up to the package author to" +" keep this list up-to-date when a new version of the package is released. " +"Package authors may also decide not to support it, if they don't see a use " +"for importing \\* from their package. For example, the file " +":file:`sound/effects/__init__.py` could contain the following code::" +msgstr "" +"Die einzige Lösung besteht darin, dass der Paketautor einen expliziten Index" +" des Pakets bereitstellt. Die Anweisung :keyword:`import` verwendet die " +"folgende Konvention: Wenn im Code von :file:`__init__.py` eines Pakets " +"eine Liste namens ``__all__`` definiert ist, wird diese als Liste der " +"Modulnamen angesehen, die importiert werden sollen, sobald auf ``from " +"package import *`` gestoßen wird. Es liegt im Ermessen des Paketautors, " +"diese Liste bei der Veröffentlichung einer neuen Version des Pakets auf dem " +"neuesten Stand zu halten. Paketautoren können sich auch dafür entscheiden, " +"diese Funktion nicht zu unterstützen, wenn sie keinen Nutzen darin sehen, " +"\\* aus ihrem Paket zu importieren. Beispielsweise könnte die Datei " +":file:`sound/effects/__init__.py` den folgenden Code enthalten::" msgid "__all__ = [\"echo\", \"surround\", \"reverse\"]" -msgstr "" +msgstr "__all__ = [\"echo\", \"surround\", \"reverse\"]" msgid "" "This would mean that ``from sound.effects import *`` would import the three " "named submodules of the :mod:`!sound.effects` package." msgstr "" +"Das würde bedeuten, dass ``from sound.effects import *`` die drei " +"genannten Submodule des Pakets :mod:`!sound.effects` importieren würde." msgid "" -"Be aware that submodules might become shadowed by locally defined names. For " -"example, if you added a ``reverse`` function to the :file:`sound/effects/" -"__init__.py` file, the ``from sound.effects import *`` would only import the " -"two submodules ``echo`` and ``surround``, but *not* the ``reverse`` " -"submodule, because it is shadowed by the locally defined ``reverse`` " -"function::" +"Be aware that submodules might become shadowed by locally defined names. For" +" example, if you added a ``reverse`` function to the " +":file:`sound/effects/__init__.py` file, the ``from sound.effects import *`` " +"would only import the two submodules ``echo`` and ``surround``, but *not* " +"the ``reverse`` submodule, because it is shadowed by the locally defined " +"``reverse`` function::" msgstr "" +"Beachte, dass Submodule durch lokal definierte Namen überschattet " +"werden können. Wenn du beispielsweise die Funktion ``reverse`` zur " +"Datei :file:`sound/effects/__init__.py` hinzugefügt hast, würde die " +"Datei ``from sound.effects import *`` nur die beiden Submodule " +"``echo`` und ``surround`` importieren, jedoch *nicht* das Submodul" +"``reverse`` , da dieses durch die lokal definierte Funktion ``reverse`` " +" überschattet wird::" msgid "" "__all__ = [\n" @@ -682,37 +1080,66 @@ msgid "" "def reverse(msg: str): # <-- this name shadows the 'reverse.py' submodule\n" " return msg[::-1] # in the case of a 'from sound.effects import *'" msgstr "" - -msgid "" -"If ``__all__`` is not defined, the statement ``from sound.effects import *`` " -"does *not* import all submodules from the package :mod:`!sound.effects` into " -"the current namespace; it only ensures that the package :mod:`!sound." -"effects` has been imported (possibly running any initialization code in :" -"file:`__init__.py`) and then imports whatever names are defined in the " -"package. This includes any names defined (and submodules explicitly loaded) " -"by :file:`__init__.py`. It also includes any submodules of the package that " -"were explicitly loaded by previous :keyword:`import` statements. Consider " -"this code::" -msgstr "" +"__all__ = [\n" +" \"echo\", # bezieht sich auf die Datei „echo.py“\n" +" \"surround\", # bezieht sich auf die Datei „surround.py“\n" +" \"reverse\", # !!! bezieht sich jetzt auf die Funktion „reverse“ !!!\n" +"]\n" +"\n" +"def reverse(msg: str): # <-- dieser Name überschreibt das Submodul „reverse.py“\n" +" return msg[::-1] # im Fall von „from sound.effects import *“" + +msgid "" +"If ``__all__`` is not defined, the statement ``from sound.effects import *``" +" does *not* import all submodules from the package :mod:`!sound.effects` " +"into the current namespace; it only ensures that the package " +":mod:`!sound.effects` has been imported (possibly running any initialization" +" code in :file:`__init__.py`) and then imports whatever names are defined in" +" the package. This includes any names defined (and submodules explicitly " +"loaded) by :file:`__init__.py`. It also includes any submodules of the " +"package that were explicitly loaded by previous :keyword:`import` " +"statements. Consider this code::" +msgstr "" +"Wenn ``__all__`` nicht definiert ist, importiert die Anweisung ``from " +"sound.effects import *`` *nicht* alle Submodule aus dem Paket " +":mod:`!sound.effects` in den aktuellen Namensraum; sie stellt lediglich " +"sicher, dass das Paket :mod:`!sound.effects` importiert wurde (wobei " +"gegebenenfalls der Initialisierungscode in :file:`__init__.py` " +"ausgeführt wird) und importiert anschließend alle Namen, die in diesem Paket" +" definiert sind. Dazu gehören alle Namen, die von :file:`__init__.py` " +"definiert wurden (sowie explizit geladene Submodule). Ebenfalls enthalten " +"sind alle Submodule des Pakets, die durch vorherige :keyword:`import` " +"-Anweisungen explizit geladen wurden. Betrachte folgenden Code::" msgid "" "import sound.effects.echo\n" "import sound.effects.surround\n" "from sound.effects import *" msgstr "" +"import sound.effects.echo\n" +"import sound.effects.surround\n" +"from sound.effects import *" msgid "" "In this example, the :mod:`!echo` and :mod:`!surround` modules are imported " -"in the current namespace because they are defined in the :mod:`!sound." -"effects` package when the ``from...import`` statement is executed. (This " -"also works when ``__all__`` is defined.)" +"in the current namespace because they are defined in the " +":mod:`!sound.effects` package when the ``from...import`` statement is " +"executed. (This also works when ``__all__`` is defined.)" msgstr "" +"In diesem Beispiel werden die Module :mod:`!echo` und :mod:`!surround`" +" in den aktuellen Namensraum importiert, da sie im Paket " +":mod:`!sound.effects` definiert sind, wenn die Anweisung " +"``from...import`` ausgeführt wird. (Dies funktioniert auch, wenn " +"``__all__`` definiert ist.)" msgid "" "Although certain modules are designed to export only names that follow " "certain patterns when you use ``import *``, it is still considered bad " "practice in production code." msgstr "" +"Obwohl bestimmte Module so konzipiert sind, dass sie bei Verwendung von " +"``import *`` nur Namen exportieren, die bestimmten Mustern entsprechen, " +"gilt dies im Produktionscode dennoch als schlechte Praxis." msgid "" "Remember, there is nothing wrong with using ``from package import " @@ -720,53 +1147,86 @@ msgid "" "importing module needs to use submodules with the same name from different " "packages." msgstr "" +"Denke daran: Es ist völlig in Ordnung, ``from package import " +"specific_submodule`` zu verwenden! Tatsächlich ist dies die empfohlene " +"Schreibweise, es sei denn, das importierende Modul muss Submodule mit " +"demselben Namen aus verschiedenen Paketen verwenden." msgid "Intra-package References" -msgstr "" +msgstr "Verweise innerhalb eines Pakets" msgid "" "When packages are structured into subpackages (as with the :mod:`!sound` " -"package in the example), you can use absolute imports to refer to submodules " -"of siblings packages. For example, if the module :mod:`!sound.filters." -"vocoder` needs to use the :mod:`!echo` module in the :mod:`!sound.effects` " -"package, it can use ``from sound.effects import echo``." +"package in the example), you can use absolute imports to refer to submodules" +" of siblings packages. For example, if the module " +":mod:`!sound.filters.vocoder` needs to use the :mod:`!echo` module in the " +":mod:`!sound.effects` package, it can use ``from sound.effects import " +"echo``." msgstr "" +"Wenn Pakete in Unterpakete gegliedert sind (wie im Beispiel beim Paket" +" :mod:`!sound` ), kannst du absolute Importe verwenden, um auf Submodule " +"von gleichrangigen Paketen zu verweisen. Wenn beispielsweise das Modul " +":mod:`!sound.filters.vocoder` das Modul :mod:`!echo` aus dem Paket " +":mod:`!sound.effects` verwenden muss, kann es ``from sound.effects " +"import echo`` verwenden." msgid "" "You can also write relative imports, with the ``from module import name`` " "form of import statement. These imports use leading dots to indicate the " -"current and parent packages involved in the relative import. From the :mod:" -"`!surround` module for example, you might use::" +"current and parent packages involved in the relative import. From the " +":mod:`!surround` module for example, you might use::" msgstr "" +"Du kannst auch relative Importe schreiben, und zwar mithilfe der " +"Importanweisung in der Form ``from module import name`` . Bei diesen " +"Importen werden führende Punkte verwendet, um das aktuelle und das " +"übergeordnete Paket anzugeben, die an dem relativen Import beteiligt sind. " +"Aus dem Modul :mod:`!surround` kannst du beispielsweise Folgendes " +"verwenden::" msgid "" "from . import echo\n" "from .. import formats\n" "from ..filters import equalizer" msgstr "" +"from . import echo\n" +"from .. import formats\n" +"from ..filters import equalizer" msgid "" "Note that relative imports are based on the name of the current module's " -"package. Since the main module does not have a package, modules intended for " -"use as the main module of a Python application must always use absolute " +"package. Since the main module does not have a package, modules intended for" +" use as the main module of a Python application must always use absolute " "imports." msgstr "" +"Beachte, dass relative Importe auf dem Namen des Pakets des aktuellen " +"Moduls basieren. Da das Hauptmodul kein Paket hat, müssen Module, die als " +"Hauptmodul einer Python-Anwendung dienen sollen, stets absolute Importe " +"verwenden." msgid "Packages in Multiple Directories" -msgstr "" +msgstr "Pakete in mehreren Verzeichnissen" msgid "" -"Packages support one more special attribute, :attr:`~module.__path__`. This " -"is initialized to be a :term:`sequence` of strings containing the name of " +"Packages support one more special attribute, :attr:`~module.__path__`. This" +" is initialized to be a :term:`sequence` of strings containing the name of " "the directory holding the package's :file:`__init__.py` before the code in " "that file is executed. This variable can be modified; doing so affects " "future searches for modules and subpackages contained in the package." msgstr "" +"Pakete unterstützen ein weiteres spezielles Attribut: " +":attr:`~module.__path__` . Dieses wird zunächst als :term:`Sequenz` von " +"Zeichenketten initialisiert, die den Namen des Verzeichnisses enthalten, in " +"dem sich die Datei :file:`__init__.py` des Pakets befindet – und zwar " +"bevor der Code in dieser Datei ausgeführt wird. Diese Variable kann geändert" +" werden; dies wirkt sich auf zukünftige Suchvorgänge nach Modulen und " +"Unterpaketen aus, die in dem Paket enthalten sind." msgid "" "While this feature is not often needed, it can be used to extend the set of " "modules found in a package." msgstr "" +"Auch wenn diese Funktion nicht oft benötigt wird, kann sie dazu dienen, die " +"in einem Paket enthaltenen Module zu erweitern." msgid "Footnotes" msgstr "Fußnoten" @@ -776,21 +1236,25 @@ msgid "" "execution of a module-level function definition adds the function name to " "the module's global namespace." msgstr "" +"Tatsächlich sind Funktionsdefinitionen ebenfalls „Anweisungen“, die " +"\"ausgeführt\“ werden; durch die Ausführung einer Funktionsdefinition auf " +"Modulebene wird der Funktionsname dem globalen Namensraum des Moduls " +"hinzugefügt." msgid "module" -msgstr "" +msgstr "module" msgid "search" -msgstr "" +msgstr "search" msgid "path" -msgstr "" +msgstr "path" msgid "sys" msgstr "sys" msgid "builtins" -msgstr "" +msgstr "builtins" msgid "__all__" -msgstr "" +msgstr "__all__" diff --git a/tutorial/venv.po b/tutorial/venv.po index 1672a69..3cf3d79 100644 --- a/tutorial/venv.po +++ b/tutorial/venv.po @@ -21,8 +21,9 @@ msgstr "" "Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" + msgid "Virtual Environments and Packages" -msgstr "" +msgstr "Virtuelle Umgebungen und Pakete" msgid "Introduction" msgstr "Einführung" @@ -34,20 +35,35 @@ msgid "" "bug has been fixed or the application may be written using an obsolete " "version of the library's interface." msgstr "" +"Python-Anwendungen verwenden häufig Pakete und Module, die nicht Teil der " +"Standardbibliothek sind. Manchmal benötigen Anwendungen eine bestimmte " +"Version einer Bibliothek, da entweder ein bestimmter Fehler behoben sein " +"muss oder die Anwendung unter Verwendung einer veralteten Version der " +"Bibliotheksschnittstelle geschrieben wurde." msgid "" "This means it may not be possible for one Python installation to meet the " "requirements of every application. If application A needs version 1.0 of a " -"particular module but application B needs version 2.0, then the requirements " -"are in conflict and installing either version 1.0 or 2.0 will leave one " +"particular module but application B needs version 2.0, then the requirements" +" are in conflict and installing either version 1.0 or 2.0 will leave one " "application unable to run." msgstr "" +"Das bedeutet, dass es unter Umständen nicht möglich ist, mit einer einzigen " +"Python-Installation die Anforderungen aller Anwendungen zu erfüllen. Wenn " +"Anwendung A die Version 1.0 eines bestimmten Moduls benötigt, Anwendung B " +"jedoch die Version 2.0, stehen die Anforderungen im Konflikt miteinander, " +"und die Installation entweder von Version 1.0 oder 2.0 führt dazu, dass eine" +" der Anwendungen nicht ausgeführt werden kann." msgid "" "The solution for this problem is to create a :term:`virtual environment`, a " "self-contained directory tree that contains a Python installation for a " "particular version of Python, plus a number of additional packages." msgstr "" +"Die Lösung für dieses Problem besteht darin, eine :term:`virtuelle Umgebung`" +" anzulegen – einen in sich geschlossenen Verzeichnisbaum, der eine Python-" +"Installation für eine bestimmte Python-Version sowie eine Reihe zusätzlicher" +" Pakete enthält." msgid "" "Different applications can then use different virtual environments. To " @@ -57,31 +73,50 @@ msgid "" "application B requires a library be upgraded to version 3.0, this will not " "affect application A's environment." msgstr "" +"Verschiedene Anwendungen können dann unterschiedliche virtuelle Umgebungen " +"nutzen. Um das zuvor genannte Beispiel widersprüchlicher Anforderungen zu " +"lösen, kann Anwendung A über eine eigene virtuelle Umgebung verfügen, in der" +" Version 1.0 installiert ist, während Anwendung B eine andere virtuelle " +"Umgebung mit Version 2.0 nutzt. Wenn für Anwendung B ein Upgrade einer " +"Bibliothek auf Version 3.0 erforderlich ist, hat dies keine Auswirkungen auf" +" die Umgebung von Anwendung A." msgid "Creating Virtual Environments" -msgstr "" +msgstr "Erstellung virtueller Umgebungen" msgid "" -"The module used to create and manage virtual environments is called :mod:" -"`venv`. :mod:`venv` will install the Python version from which the command " -"was run (as reported by the :option:`--version` option). For instance, " -"executing the command with ``python3.12`` will install version 3.12." -msgstr "" +"The module used to create and manage virtual environments is called " +":mod:`venv`. :mod:`venv` will install the Python version from which the " +"command was run (as reported by the :option:`--version` option). For " +"instance, executing the command with ``python3.12`` will install version " +"3.12." +msgstr "" +"Das Modul zum Erstellen und Verwalten virtueller Umgebungen heißt " +":mod:`venv` . Mit dem Befehl :mod:`venv` wird die Python-Version " +"installiert, von der aus der Befehl ausgeführt wurde (wie durch die Option " +" :option:`--version` angegeben). Wenn du den Befehl beispielsweise mit " +"``python3.12`` ausführst, wird Version 3.12 installiert." msgid "" "To create a virtual environment, decide upon a directory where you want to " "place it, and run the :mod:`venv` module as a script with the directory " "path::" msgstr "" +"Um eine virtuelle Umgebung zu erstellen, lege ein Verzeichnis fest, in " +"dem du diese ablegen möchtest, und führe das Modul :mod:`venv` als " +"Skript mit dem Verzeichnispfad aus::" msgid "python -m venv tutorial-env" -msgstr "" +msgstr "python -m venv tutorial-env" msgid "" "This will create the ``tutorial-env`` directory if it doesn't exist, and " "also create directories inside it containing a copy of the Python " "interpreter and various supporting files." msgstr "" +"Dadurch wird das Verzeichnis ``tutorial-env`` angelegt, falls es noch " +"nicht existiert, und es werden darin Unterverzeichnisse erstellt, die eine " +"Kopie des Python-Interpreters sowie verschiedene Hilfsdateien enthalten." msgid "" "A common directory location for a virtual environment is ``.venv``. This " @@ -90,27 +125,39 @@ msgid "" "prevents clashing with ``.env`` environment variable definition files that " "some tooling supports." msgstr "" +"Ein gängiger Speicherort für eine virtuelle Umgebung ist ``.venv`` . " +"Durch diesen Namen bleibt das Verzeichnis in der Regel in Ihrer Shell " +"verborgen und stört somit nicht, während der Name gleichzeitig verdeutlicht," +" wozu das Verzeichnis dient. Außerdem wird dadurch eine Kollision mit den " +"Definitionsdateien der Umgebungsvariablen ``.env`` vermieden, die von " +"einigen Tools unterstützt werden." msgid "Once you've created a virtual environment, you may activate it." msgstr "" +"Sobald du eine virtuelle Umgebung erstellt hast, kannst du diese " +"aktivieren." msgid "On Windows, run::" -msgstr "" +msgstr "Führe unter Windows Folgendes aus::" msgid "tutorial-env\\Scripts\\activate" -msgstr "" +msgstr "tutorial-env\\Scripts\\activate" msgid "On Unix or MacOS, run::" -msgstr "" +msgstr "Unter Unix oder macOS führe folgenden Befehl aus::" msgid "source tutorial-env/bin/activate" -msgstr "" +msgstr "source tutorial-env/bin/activate" msgid "" "(This script is written for the bash shell. If you use the :program:`csh` " "or :program:`fish` shells, there are alternate ``activate.csh`` and " "``activate.fish`` scripts you should use instead.)" msgstr "" +"(Dieses Skript wurde für die Bash-Shell geschrieben. Wenn du die Shells " +":program:`csh` oder :program:`fish` verwendest, solltest du " +"stattdessen die alternativen Skripte unter ``activate.csh`` und " +"``activate.fish`` verwenden.)" msgid "" "Activating the virtual environment will change your shell's prompt to show " @@ -118,6 +165,11 @@ msgid "" "running ``python`` will get you that particular version and installation of " "Python. For example:" msgstr "" +"Durch das Aktivieren der virtuellen Umgebung ändert sich die " +"Eingabeaufforderung deiner Shell so, dass angezeigt wird, welche virtuelle " +"Umgebung du gerade verwendest, und die Umgebung wird so angepasst, dass du " +"mit dem Befehl ``python`` genau diese Version und Installation von " +"Python aufrufst. Zum Beispiel:" msgid "" "$ source ~/envs/tutorial-env/bin/activate\n" @@ -130,36 +182,69 @@ msgid "" "'~/envs/tutorial-env/lib/python3.5/site-packages']\n" ">>>" msgstr "" +"$ source ~/envs/tutorial-env/bin/activate\n" +"(tutorial-env) $ python\n" +"Python 3.5.1 (default, May 6 2016, 10:59:36)\n" +" ...\n" +">>> import sys\n" +">>> sys.path\n" +"['', '/usr/local/lib/python35.zip', ...,\n" +"'~/envs/tutorial-env/lib/python3.5/site-packages']\n" +">>>" + +msgid "" +"Note that the activated virtual environment does not alter the " +"``PYTHONPATH`` variable in any way. This may lead to unexpected results if " +"the path includes references to code which is incompatible with the Python " +"version the virtual environment is using. The best practice is to ``unset " +"PYTHONPATH`` in bash or the equivalent for the shell you are using." +msgstr "" +"Beachte, dass die aktivierte virtuelle Umgebung die Variable " +"``PYTHONPATH`` in keiner Weise verändert. Dies kann zu unerwarteten " +"Ergebnissen führen, wenn der Pfad Verweise auf Code enthält, der mit der von" +" der virtuellen Umgebung verwendeten Python-Version nicht kompatibel ist. Es" +" empfiehlt sich, in Bash den Befehl ``unset PYTHONPATH`` auszuführen " +"oder den entsprechenden Befehl für die von dir verwendeten Shell." msgid "To deactivate a virtual environment, type::" -msgstr "" +msgstr "Um eine virtuelle Umgebung zu deaktivieren, gebe Folgendes ein::" msgid "deactivate" -msgstr "" +msgstr "deactivate" msgid "into the terminal." -msgstr "" +msgstr "in das Terminal." msgid "Managing Packages with pip" -msgstr "" +msgstr "Pakete mit pip verwalten" msgid "" -"You can install, upgrade, and remove packages using a program called :" -"program:`pip`. By default ``pip`` will install packages from the `Python " -"Package Index `_. You can browse the Python Package Index " -"by going to it in your web browser." +"You can install, upgrade, and remove packages using a program called " +":program:`pip`. By default ``pip`` will install packages from the `Python " +"Package Index `_. You can browse the Python Package Index" +" by going to it in your web browser." msgstr "" +"Mit dem Programm :program:`pip` kannst du Pakete installieren, " +"aktualisieren und entfernen. Standardmäßig installiert ``pip`` Pakete " +"aus dem \"Python Package Index\“ ( _). Du kannst den Python" +" Package Index durchsuchen, indem du die entsprechende Seite in deinem " +"Webbrowser aufrufst." msgid "" -"``pip`` has a number of subcommands: \"install\", \"uninstall\", \"freeze\", " -"etc. (Consult the :ref:`installing-index` guide for complete documentation " -"for ``pip``.)" +"``pip`` has a number of subcommands: \"install\", \"uninstall\", \"freeze\"," +" etc. (Consult the :ref:`installing-index` guide for complete documentation" +" for ``pip``.)" msgstr "" +"``pip`` verfügt über eine Reihe von Unterbefehlen: \"install\“, \"uninstall\“, " +"\"freeze\“ usw. (Die vollständige Dokumentation zu ``pip`` findest du im " +"Handbuch :ref:`installing-index` .)" msgid "" "You can install the latest version of a package by specifying a package's " "name:" msgstr "" +"Du kannst die neueste Version eines Pakets installieren, indem du den Namen " +"des Pakets angibst:" msgid "" "(tutorial-env) $ python -m pip install novas\n" @@ -169,11 +254,19 @@ msgid "" " Running setup.py install for novas\n" "Successfully installed novas-3.1.1.3" msgstr "" +"(tutorial-env) $ python -m pip install novas\n" +"Collecting novas\n" +" Downloading novas-3.1.1.3.tar.gz (136kB)\n" +"Installing collected packages: novas\n" +" Running setup.py install for novas\n" +"Successfully installed novas-3.1.1.3" msgid "" "You can also install a specific version of a package by giving the package " "name followed by ``==`` and the version number:" msgstr "" +"Du kannst auch eine bestimmte Version eines Pakets installieren, indem du " +"den Paketnamen gefolgt von ``==`` und der Versionsnummer angibst:" msgid "" "(tutorial-env) $ python -m pip install requests==2.6.0\n" @@ -182,13 +275,23 @@ msgid "" "Installing collected packages: requests\n" "Successfully installed requests-2.6.0" msgstr "" +"(tutorial-env) $ python -m pip install requests==2.6.0\n" +"Collecting requests==2.6.0\n" +" Using cached requests-2.6.0-py2.py3-none-any.whl\n" +"Installing collected packages: requests\n" +"Successfully installed requests-2.6.0" msgid "" "If you re-run this command, ``pip`` will notice that the requested version " "is already installed and do nothing. You can supply a different version " -"number to get that version, or you can run ``python -m pip install --" -"upgrade`` to upgrade the package to the latest version:" +"number to get that version, or you can run ``python -m pip install " +"--upgrade`` to upgrade the package to the latest version:" msgstr "" +"Wenn du diesen Befehl erneut ausführst, erkennt ``pip`` , dass die " +"angeforderte Version bereits installiert ist, und führt keine Aktion durch. " +"Du kannst eine andere Versionsnummer angeben, um diese Version zu erhalten, " +"oder du kannst ``python -m pip install --upgrade`` ausführen, um das " +"Paket auf die neueste Version zu aktualisieren:" msgid "" "(tutorial-env) $ python -m pip install --upgrade requests\n" @@ -199,15 +302,25 @@ msgid "" " Successfully uninstalled requests-2.6.0\n" "Successfully installed requests-2.7.0" msgstr "" +"(tutorial-env) $ python -m pip install --upgrade requests\n" +"Collecting requests\n" +"Installing collected packages: requests\n" +" Found existing installation: requests 2.6.0\n" +" Uninstalling requests-2.6.0:\n" +" Successfully uninstalled requests-2.6.0\n" +"Successfully installed requests-2.7.0" msgid "" "``python -m pip uninstall`` followed by one or more package names will " "remove the packages from the virtual environment." msgstr "" +"``python -m pip uninstall`` gefolgt von einem oder mehrere " +"Paketnamen entfernt die Pakete aus der virtuellen Umgebung»." msgid "" "``python -m pip show`` will display information about a particular package:" msgstr "" +"``python -m pip show`` zeigt Informationen zu einem bestimmten Paket an:" msgid "" "(tutorial-env) $ python -m pip show requests\n" @@ -223,11 +336,25 @@ msgid "" "Location: /Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages\n" "Requires:" msgstr "" +"(tutorial-env) $ python -m pip show requests\n" +"---\n" +"Metadata-Version: 2.0\n" +"Name: requests\n" +"Version: 2.7.0\n" +"Summary: Python HTTP for Humans.\n" +"Home-page: http://python-requests.org\n" +"Author: Kenneth Reitz\n" +"Author-email: me@kennethreitz.com\n" +"License: Apache 2.0\n" +"Location: /Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages\n" +"Requires:" msgid "" "``python -m pip list`` will display all of the packages installed in the " "virtual environment:" msgstr "" +"``python -m pip list`` zeigt alle in der virtuellen Umgebung installierten " +"Pakete an:" msgid "" "(tutorial-env) $ python -m pip list\n" @@ -237,6 +364,12 @@ msgid "" "requests (2.7.0)\n" "setuptools (16.0)" msgstr "" +"(tutorial-env) $ python -m pip list\n" +"novas (3.1.1.3)\n" +"numpy (1.9.2)\n" +"pip (7.0.3)\n" +"requests (2.7.0)\n" +"setuptools (16.0)" msgid "" "``python -m pip freeze`` will produce a similar list of the installed " @@ -244,6 +377,10 @@ msgid "" "expects. A common convention is to put this list in a ``requirements.txt`` " "file:" msgstr "" +"``python -m pip freeze`` gibt eine ähnliche Liste der installierten Pakete " +"aus, allerdings im Format, das ``python -m pip install`` erwartet. Es ist " +"üblich, diese Liste in einer Datei namens ``requirements.txt`` " +"abzulegen:" msgid "" "(tutorial-env) $ python -m pip freeze > requirements.txt\n" @@ -252,12 +389,21 @@ msgid "" "numpy==1.9.2\n" "requests==2.7.0" msgstr "" +"(tutorial-env) $ python -m pip freeze > requirements.txt\n" +"(tutorial-env) $ cat requirements.txt\n" +"novas==3.1.1.3\n" +"numpy==1.9.2\n" +"requests==2.7.0" msgid "" "The ``requirements.txt`` can then be committed to version control and " -"shipped as part of an application. Users can then install all the necessary " -"packages with ``install -r``:" +"shipped as part of an application. Users can then install all the necessary" +" packages with ``install -r``:" msgstr "" +"Die ``requirements.txt`` kann anschließend in die Versionskontrolle " +"übernommen und als Teil einer Anwendung ausgeliefert werden. Benutzer können" +" dann alle erforderlichen Pakete mit dem Befehl ``install -r`` " +"installieren:" msgid "" "(tutorial-env) $ python -m pip install -r requirements.txt\n" @@ -271,6 +417,16 @@ msgid "" " Running setup.py install for novas\n" "Successfully installed novas-3.1.1.3 numpy-1.9.2 requests-2.7.0" msgstr "" +"(tutorial-env) $ python -m pip install -r requirements.txt\n" +"Collecting novas==3.1.1.3 (from -r requirements.txt (line 1))\n" +" ...\n" +"Collecting numpy==1.9.2 (from -r requirements.txt (line 2))\n" +" ...\n" +"Collecting requests==2.7.0 (from -r requirements.txt (line 3))\n" +" ...\n" +"Installing collected packages: novas, numpy, requests\n" +" Running setup.py install for novas\n" +"Successfully installed novas-3.1.1.3 numpy-1.9.2 requests-2.7.0" msgid "" "``pip`` has many more options. Consult the :ref:`installing-index` guide " @@ -278,3 +434,7 @@ msgid "" "want to make it available on the Python Package Index, consult the `Python " "packaging user guide`_." msgstr "" +"``pip`` bietet viele weitere Optionen. Die vollständige Dokumentation zu " +"``pip`` findest du im Handbuch :ref:`installing-index` . Wenn du ein " +"Paket erstellt hast und es im Python Package Index veröffentlichen möchtest," +" lese bitte das `Python Packaging User Guide`_."