# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR , YEAR.
#
# Translators:
# python-doc bot, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.11\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-22 20:37+0000\n"
"PO-Revision-Date: 2025-09-22 16:51+0000\n"
"Last-Translator: python-doc bot, 2025\n"
"Language-Team: Portuguese (Brazil) (https://app.transifex.com/python-doc/"
"teams/5390/pt_BR/)\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % "
"1000000 == 0 ? 1 : 2;\n"
#: ../../tutorial/datastructures.rst:5
msgid "Data Structures"
msgstr "Estruturas de dados"
#: ../../tutorial/datastructures.rst:7
msgid ""
"This chapter describes some things you've learned about already in more "
"detail, and adds some new things as well."
msgstr ""
"Esse captulo descreve algumas coisas que voc j aprendeu em detalhes e "
"adiciona algumas coisas novas tambm."
#: ../../tutorial/datastructures.rst:13
msgid "More on Lists"
msgstr "Mais sobre listas"
#: ../../tutorial/datastructures.rst:15
msgid ""
"The list data type has some more methods. Here are all of the methods of "
"list objects:"
msgstr ""
"O tipo de dado lista tem ainda mais mtodos. Aqui esto apresentados todos "
"os mtodos de objetos do tipo lista:"
#: ../../tutorial/datastructures.rst:22
msgid ""
"Add an item to the end of the list. Equivalent to ``a[len(a):] = [x]``."
msgstr "Adiciona um item ao fim da lista. Equivalente a ``a[len(a):] = [x]``."
#: ../../tutorial/datastructures.rst:28
msgid ""
"Extend the list by appending all the items from the iterable. Equivalent to "
"``a[len(a):] = iterable``."
msgstr ""
"Prolonga a lista, adicionando no fim todos os elementos do argumento "
"`iterable` passado como parmetro. Equivalente a ``a[len(a):] = iterable``."
#: ../../tutorial/datastructures.rst:35
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 ""
"Insere um item em uma dada posio. O primeiro argumento o ndice do "
"elemento antes do qual ser feita a insero, assim ``a.insert(0, x)`` "
"insere um elemento na frente da lista e ``a.insert(len(a), x)`` e equivale a "
"``a.append(x)``."
#: ../../tutorial/datastructures.rst:43
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."
msgstr ""
"Remove o primeiro item encontrado na lista cujo valor igual a *x*. Se no "
"existir valor igual, uma exceo :exc:`ValueError` levantada."
#: ../../tutorial/datastructures.rst:50
msgid ""
"Remove the item at the given position in the list, and return it. If no "
"index is specified, ``a.pop()`` removes and returns the last item in the "
"list. It raises an :exc:`IndexError` if the list is empty or the index is "
"outside the list range."
msgstr ""
"Remove o item na posio fornecida na lista e retorna. Se nenhum ndice for "
"especificado, ``a.pop()`` remove e retorna o ltimo item da lista. Levanta "
"um :exc:`IndexError` se a lista estiver vazia ou o ndice estiver fora do "
"intervalo da lista."
#: ../../tutorial/datastructures.rst:59
msgid "Remove all items from the list. Equivalent to ``del a[:]``."
msgstr "Remove todos os itens de uma lista. Equivalente a ``del a[:]``."
#: ../../tutorial/datastructures.rst:65
msgid ""
"Return zero-based index in the list of the first item whose value is equal "
"to *x*. Raises a :exc:`ValueError` if there is no such item."
msgstr ""
"Devolve o ndice base-zero do primeiro item cujo valor igual a *x*, "
"levantando :exc:`ValueError` se este valor no existe."
#: ../../tutorial/datastructures.rst:68
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."
msgstr ""
"Os argumentos opcionais *start* e *end* so interpretados como nas notaes "
"de fatiamento e so usados para limitar a busca para uma subsequncia "
"especfica da lista. O ndice retornado calculado relativo ao comeo da "
"sequncia inteira e no referente ao argumento *start*."
#: ../../tutorial/datastructures.rst:77
msgid "Return the number of times *x* appears in the list."
msgstr "Devolve o nmero de vezes em que *x* aparece na lista."
#: ../../tutorial/datastructures.rst:83
msgid ""
"Sort the items of the list in place (the arguments can be used for sort "
"customization, see :func:`sorted` for their explanation)."
msgstr ""
"Ordena os itens na lista (os argumentos podem ser usados para personalizar a "
"ordenao, veja a funo :func:`sorted` para maiores explicaes)."
#: ../../tutorial/datastructures.rst:90
msgid "Reverse the elements of the list in place."
msgstr "Inverte a ordem dos elementos na lista."
#: ../../tutorial/datastructures.rst:96
msgid "Return a shallow copy of the list. Equivalent to ``a[:]``."
msgstr "Devolve uma cpia rasa da lista. Equivalente a ``a[:]``."
#: ../../tutorial/datastructures.rst:99
msgid "An example that uses most of the list methods::"
msgstr "Um exemplo que usa a maior parte dos mtodos das listas::"
#: ../../tutorial/datastructures.rst:122
msgid ""
"You might have noticed that methods like ``insert``, ``remove`` or ``sort`` "
"that only modify the list have no return value printed -- they return the "
"default ``None``. [#]_ This is a design principle for all mutable data "
"structures in Python."
msgstr ""
"Voc pode ter percebido que mtodos como ``insert``, ``remove`` ou ``sort``, "
"que apenas modificam a lista, no tm valor de retorno impresso -- eles "
"retornam o ``None`` padro. [#]_ Isto um princpio de design para todas as "
"estruturas de dados mutveis em Python."
#: ../../tutorial/datastructures.rst:127
msgid ""
"Another thing you might notice is that not all data can be sorted or "
"compared. For instance, ``[None, 'hello', 10]`` doesn't sort because "
"integers can't be compared to strings and *None* can't be compared to 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 ""
"Outra coisa que voc deve estar atento que nem todos os dados podem ser "
"ordenados ou comparados. Por exemplo, , ``[None, 'hello', 10]`` no podem "
"ser ordenados, pois inteiros no podem ser comparados a strings e *None* no "
"pode ser comparado a nenhum outro tipo. Alm disso, existem alguns tipos de "
"dados que no possuem uma relao de ordem definida. Por exemplo, ``3+4j < "
"5+7j`` no uma comparao vlida."
#: ../../tutorial/datastructures.rst:138
msgid "Using Lists as Stacks"
msgstr "Usando listas como pilhas"
#: ../../tutorial/datastructures.rst:143
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::"
msgstr ""
"Os mtodos de lista tornam muito fcil utilizar listas como pilhas, onde o "
"item adicionado por ltimo o primeiro a ser recuperado (poltica ltimo a "
"entrar, primeiro a sair). Para adicionar um item ao topo da pilha, use :"
"meth:`~list.append`. Para recuperar um item do topo da pilha use :meth:"
"`~list.pop` sem nenhum ndice explcito. Por exemplo::"
#: ../../tutorial/datastructures.rst:168
msgid "Using Lists as Queues"
msgstr "Usando listas como filas"
#: ../../tutorial/datastructures.rst:172
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 "
"(because all of the other elements have to be shifted by one)."
msgstr ""
"Voc tambm pode usar uma lista como uma fila, onde o primeiro item "
"adicionado o primeiro a ser recuperado (poltica primeiro a entrar, "
"primeiro a sair); porm, listas no so eficientes para esta finalidade. "
"Embora *appends* e *pops* no final da lista sejam rpidos, fazer *inserts* "
"ou *pops* no incio da lista lento (porque todos os demais elementos tm "
"que ser deslocados)."
#: ../../tutorial/datastructures.rst:178
msgid ""
"To implement a queue, use :class:`collections.deque` which was designed to "
"have fast appends and pops from both ends. For example::"
msgstr ""
"Para implementar uma fila, use a classe :class:`collections.deque` que foi "
"projetada para permitir *appends* e *pops* eficientes nas duas extremidades. "
"Por exemplo::"
#: ../../tutorial/datastructures.rst:196
msgid "List Comprehensions"
msgstr "Compreenses de lista"
#: ../../tutorial/datastructures.rst:198
msgid ""
"List comprehensions provide a concise way to create lists. Common "
"applications are to make new lists where each element is the result of some "
"operations applied to each member of another sequence or iterable, or to "
"create a subsequence of those elements that satisfy a certain condition."
msgstr ""
"Compreenses de lista fornece uma maneira concisa de criar uma lista. "
"Aplicaes comuns so criar novas listas onde cada elemento o resultado de "
"alguma operao aplicada a cada elemento de outra sequncia ou itervel, ou "
"criar uma subsequncia de elementos que satisfaam uma certa condio. (N.d."
"T. o termo original em ingls *list comprehensions*, muito utilizado no "
"Brasil; tambm se usa a abreviao *listcomp*)."
#: ../../tutorial/datastructures.rst:203
msgid "For example, assume we want to create a list of squares, like::"
msgstr ""
"Por exemplo, suponha que queremos criar uma lista de quadrados, assim::"
#: ../../tutorial/datastructures.rst:212
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 ""
"Note que isto cria (ou sobrescreve) uma varivel chamada ``x`` que ainda "
"existe aps o trmino do lao. Podemos calcular a lista dos quadrados sem "
"qualquer efeito colateral usando::"
#: ../../tutorial/datastructures.rst:218
msgid "or, equivalently::"
msgstr "ou, de maneira equivalente::"
#: ../../tutorial/datastructures.rst:222
msgid "which is more concise and readable."
msgstr "que mais conciso e legvel."
#: ../../tutorial/datastructures.rst:224
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::"
msgstr ""
"Um compreenso de lista consiste de um par de colchetes contendo uma "
"expresso seguida de uma clusula :keyword:`!for`, e ento zero ou mais "
"clusulas :keyword:`!for` ou :keyword:`!if`. O resultado ser uma nova lista "
"resultante da avaliao da expresso no contexto das clusulas :keyword:`!"
"for` e :keyword:`!if`. Por exemplo, essa compreenso combina os elementos de "
"duas listas se eles forem diferentes::"
#: ../../tutorial/datastructures.rst:234
msgid "and it's equivalent to::"
msgstr "e equivalente a::"
#: ../../tutorial/datastructures.rst:245
msgid ""
"Note how the order of the :keyword:`for` and :keyword:`if` statements is the "
"same in both these snippets."
msgstr ""
"Note como a ordem das instrues :keyword:`for` e :keyword:`if` a mesma em "
"ambos os trechos."
#: ../../tutorial/datastructures.rst:248
msgid ""
"If the expression is a tuple (e.g. the ``(x, y)`` in the previous example), "
"it must be parenthesized. ::"
msgstr ""
"Se a expresso uma tupla (ex., ``(x, y)`` no exemplo anterior), ela deve "
"ser inserida entre parnteses. ::"
#: ../../tutorial/datastructures.rst:279
msgid ""
"List comprehensions can contain complex expressions and nested functions::"
msgstr ""
"Compreenses de lista podem conter expresses complexas e funes aninhadas::"
#: ../../tutorial/datastructures.rst:286
msgid "Nested List Comprehensions"
msgstr "Compreenses de lista aninhadas"
#: ../../tutorial/datastructures.rst:288
msgid ""
"The initial expression in a list comprehension can be any arbitrary "
"expression, including another list comprehension."
msgstr ""
"A expresso inicial em uma compreenso de lista pode ser qualquer expresso "
"arbitrria, incluindo outra compreenso de lista."
#: ../../tutorial/datastructures.rst:291
msgid ""
"Consider the following example of a 3x4 matrix implemented as a list of 3 "
"lists of length 4::"
msgstr ""
"Observe este exemplo de uma matriz 3x4 implementada como uma lista de 3 "
"listas de comprimento 4::"
#: ../../tutorial/datastructures.rst:300
msgid "The following list comprehension will transpose rows and columns::"
msgstr "A compreenso de lista abaixo transpe as linhas e colunas::"
#: ../../tutorial/datastructures.rst:305
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 "
"equivalent to::"
msgstr ""
"Como vimos na seo anterior, a compreenso de lista interna computada no "
"contexto da clusula :keyword:`for` seguinte, portanto o exemplo acima "
"equivale a::"
#: ../../tutorial/datastructures.rst:316
msgid "which, in turn, is the same as::"
msgstr "e isso, por sua vez, faz o mesmo que isto::"
#: ../../tutorial/datastructures.rst:329
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::"
msgstr ""
"Na prtica, voc deve dar preferncia a funes embutidas em vez de "
"instrues complexas. A funo :func:`zip` resolve muito bem este caso de "
"uso::"
#: ../../tutorial/datastructures.rst:335
msgid ""
"See :ref:`tut-unpacking-arguments` for details on the asterisk in this line."
msgstr ""
"Veja :ref:`tut-unpacking-arguments` para entender o uso do asterisco neste "
"exemplo."
#: ../../tutorial/datastructures.rst:340
msgid "The :keyword:`!del` statement"
msgstr "A instruo :keyword:`!del`"
#: ../../tutorial/datastructures.rst:342
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::"
msgstr ""
"Existe uma maneira de remover um item de uma lista usando seu ndice no "
"lugar do seu valor: a instruo :keyword:`del`. Ele difere do mtodo :meth:"
"`~list.pop` que devolve um valor. A instruo :keyword:`!del` pode tambm "
"ser utilizada para remover fatias de uma lista ou limpar a lista inteira "
"(que fizemos antes por atribuio de uma lista vazia fatia ``a[:]``). Por "
"exemplo::"
#: ../../tutorial/datastructures.rst:359
msgid ":keyword:`del` can also be used to delete entire variables::"
msgstr ""
":keyword:`del` tambm pode ser usado para remover totalmente uma varivel::"
#: ../../tutorial/datastructures.rst:363
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 ""
"Referenciar a varivel ``a`` depois de sua remoo constitui erro (pelo "
"menos at que seja feita uma nova atribuio para ela). Encontraremos outros "
"usos para a instruo :keyword:`del` mais tarde."
#: ../../tutorial/datastructures.rst:370
msgid "Tuples and Sequences"
msgstr "Tuplas e Sequncias"
#: ../../tutorial/datastructures.rst:372
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*."
msgstr ""
"Vimos que listas e strings tm muitas propriedades em comum, como indexao "
"e operaes de fatiamento. Elas so dois exemplos de *sequncias* (veja :ref:"
"`typesseq`). Como Python uma linguagem em evoluo, outros tipos de "
"sequncias podem ser adicionados. Existe ainda um outro tipo de sequncia "
"padro na linguagem: a *tupla*."
#: ../../tutorial/datastructures.rst:378
msgid ""
"A tuple consists of a number of values separated by commas, for instance::"
msgstr ""
"Uma tupla consiste em uma sequncia de valores separados por vrgulas, por "
"exemplo::"
#: ../../tutorial/datastructures.rst:400
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 "
"which contain mutable objects, such as lists."
msgstr ""
"Como voc pode ver no trecho acima, na sada do console as tuplas so sempre "
"envolvidas por parnteses, assim tuplas aninhadas podem ser lidas "
"corretamente. Na criao, tuplas podem ser envolvidas ou no por parnteses, "
"desde que o contexto no exija os parnteses (como no caso da tupla dentro "
"de uma expresso maior). No possvel atribuir itens individuais de uma "
"tupla, contudo possvel criar tuplas que contenham objetos mutveis, como "
"listas."
#: ../../tutorial/datastructures.rst:407
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 ""
"Apesar de tuplas serem similares a listas, elas so frequentemente "
"utilizadas em situaes diferentes e com propsitos distintos. Tuplas so :"
"term:`imutveis `, e usualmente contm uma sequncia heterognea "
"de elementos que so acessados via desempacotamento (ver a seguir nessa "
"seo) ou ndice (ou mesmo por um atributo no caso de :func:`namedtuples "
"`). Listas so :term:`mutveis `, e seus "
"elementos geralmente so homogneos e so acessados iterando sobre a lista."
#: ../../tutorial/datastructures.rst:415
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 ""
"Um problema especial a criao de tuplas contendo 0 ou 1 itens: a sintaxe "
"usa certos truques para acomodar estes casos. Tuplas vazias so construdas "
"por um par de parnteses vazios; uma tupla unitria construda por um "
"nico valor seguido de uma vrgula (no basta colocar um nico valor entre "
"parnteses). Feio, mas funciona. Por exemplo::"
#: ../../tutorial/datastructures.rst:430
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 ""
"A instruo ``t = 12345, 54321, 'bom dia!'`` um exemplo de *empacotamento "
"de tupla*: os valores ``12345``, ``54321`` e ``'bom dia!'`` so empacotados "
"em uma tupla. A operao inversa tambm possvel::"
#: ../../tutorial/datastructures.rst:436
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."
msgstr ""
"Isso chamado, apropriadamente, de *desempacotamento de sequncia* e "
"funciona para qualquer sequncia no lado direito. O desempacotamento de "
"sequncia requer que haja tantas variveis no lado esquerdo do sinal de "
"igual, quanto existem de elementos na sequncia. Observe que a atribuio "
"mltipla , na verdade, apenas uma combinao de empacotamento de tupla e "
"desempacotamento de sequncia."
#: ../../tutorial/datastructures.rst:446
msgid "Sets"
msgstr "Conjuntos"
#: ../../tutorial/datastructures.rst:448
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."
msgstr ""
"Python tambm inclui um tipo de dados para conjuntos, chamado ``set``. Um "
"conjunto uma coleo desordenada de elementos, sem elementos repetidos. "
"Usos comuns para conjuntos incluem a verificao eficiente da existncia de "
"objetos e a eliminao de itens duplicados. Conjuntos tambm suportam "
"operaes matemticas como unio, interseo, diferena e diferena "
"simtrica."
#: ../../tutorial/datastructures.rst:453
msgid ""
"Curly braces or the :func:`set` function can be used to create sets. Note: "
"to create an empty set you have to use ``set()``, not ``{}``; the latter "
"creates an empty dictionary, a data structure that we discuss in the next "
"section."
msgstr ""
"Chaves ou a funo :func:`set` podem ser usados para criar conjuntos. Note: "
"para criar um conjunto vazio voc precisa usar ``set()``, no ``{}``; este "
"ltimo cria um dicionrio vazio, uma estrutura de dados que discutiremos na "
"prxima seo."
#: ../../tutorial/datastructures.rst:457
msgid "Here is a brief demonstration::"
msgstr "Uma pequena demonstrao::"
#: ../../tutorial/datastructures.rst:482
msgid ""
"Similarly to :ref:`list comprehensions `, set comprehensions "
"are also supported::"
msgstr ""
"Da mesma forma que :ref:`compreenso de listas `, "
"compreenses de conjunto tambm so suportadas::"
#: ../../tutorial/datastructures.rst:493
msgid "Dictionaries"
msgstr "Dicionrios"
#: ../../tutorial/datastructures.rst:495
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 ""
"Outra estrutura de dados muito til embutida em Python o *dicionrio*, "
"cujo tipo ``dict`` (ver :ref:`typesmapping`). Dicionrios so tambm "
"chamados de memria associativa ou vetor associativo em outras "
"linguagens. Diferente de sequncias que so indexadas por inteiros, "
"dicionrios so indexados por chaves (*keys*), que podem ser de qualquer "
"tipo imutvel (como strings e inteiros). Tuplas tambm podem ser chaves se "
"contiverem apenas strings, inteiros ou outras tuplas. Se a tupla contiver, "
"direta ou indiretamente, qualquer valor mutvel, no poder ser chave. "
"Listas no podem ser usadas como chaves porque podem ser modificadas "
"*internamente* pela atribuio em ndices ou fatias, e por mtodos como :"
"meth:`~list.append` e :meth:`~list.extend`."
#: ../../tutorial/datastructures.rst:506
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 ""
"Um bom modelo mental imaginar um dicionrio como um conjunto no-ordenado "
"de pares *chave:valor*, onde as chaves so nicas em uma dada instncia do "
"dicionrio. Dicionrios so delimitados por chaves: ``{}``, e contm uma "
"lista de pares chave:valor separada por vrgulas. Dessa forma tambm ser "
"exibido o contedo de um dicionrio no console do Python. O dicionrio vazio "
" ``{}``."
#: ../../tutorial/datastructures.rst:512
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. It is an error to "
"extract a value using a non-existent key."
msgstr ""
"As principais operaes em um dicionrio so armazenar e recuperar valores a "
"partir de chaves. Tambm possvel remover um par *chave:valor* com o "
"comando ``del``. Se voc armazenar um valor utilizando uma chave j "
"presente, o antigo valor ser substitudo pelo novo. Se tentar recuperar um "
"valor usando uma chave inexistente, ser gerado um erro."
#: ../../tutorial/datastructures.rst:518
msgid ""
"Performing ``list(d)`` on a dictionary returns a list of all the keys used "
"in the dictionary, in insertion order (if you want it sorted, just use "
"``sorted(d)`` instead). To check whether a single key is in the dictionary, "
"use the :keyword:`in` keyword."
msgstr ""
"Executar ``list(d)`` em um dicionrio devolve a lista de todas as chaves "
"presentes no dicionrio, na ordem de insero (se desejar orden-las basta "
"usar a funo ``sorted(d)``). Para verificar a existncia de uma chave, use "
"o operador :keyword:`in`."
#: ../../tutorial/datastructures.rst:523
msgid "Here is a small example using a dictionary::"
msgstr "A seguir, um exemplo de uso do dicionrio::"
#: ../../tutorial/datastructures.rst:544
msgid ""
"The :func:`dict` constructor builds dictionaries directly from sequences of "
"key-value pairs::"
msgstr ""
"O construtor :func:`dict` produz dicionrios diretamente de sequncias de "
"pares chave-valor::"
#: ../../tutorial/datastructures.rst:550
msgid ""
"In addition, dict comprehensions can be used to create dictionaries from "
"arbitrary key and value expressions::"
msgstr ""
"Alm disso, as compreenses de dicionrios podem ser usadas para criar "
"dicionrios a partir de expresses arbitrrias de chave e valor::"
#: ../../tutorial/datastructures.rst:556
msgid ""
"When the keys are simple strings, it is sometimes easier to specify pairs "
"using keyword arguments::"
msgstr ""
"Quando chaves so strings simples, mais fcil especificar os pares usando "
"argumentos nomeados no construtor::"
#: ../../tutorial/datastructures.rst:566
msgid "Looping Techniques"
msgstr "Tcnicas de iterao"
#: ../../tutorial/datastructures.rst:568
msgid ""
"When looping through dictionaries, the key and corresponding value can be "
"retrieved at the same time using the :meth:`~dict.items` method. ::"
msgstr ""
"Ao iterar sobre dicionrios, a chave e o valor correspondente podem ser "
"obtidos simultaneamente usando o mtodo :meth:`~dict.items`. ::"
#: ../../tutorial/datastructures.rst:578
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 ""
"Ao iterar sobre sequncias, a posio e o valor correspondente podem ser "
"obtidos simultaneamente usando a funo :func:`enumerate`. ::"
#: ../../tutorial/datastructures.rst:588
msgid ""
"To loop over two or more sequences at the same time, the entries can be "
"paired with the :func:`zip` function. ::"
msgstr ""
"Para percorrer duas ou mais sequncias ao mesmo tempo, as entradas podem ser "
"pareadas com a funo :func:`zip`. ::"
#: ../../tutorial/datastructures.rst:600
msgid ""
"To loop over a sequence in reverse, first specify the sequence in a forward "
"direction and then call the :func:`reversed` function. ::"
msgstr ""
"Para percorrer uma sequncia em ordem inversa, chame a funo :func:"
"`reversed` com a sequncia na ordem original. ::"
#: ../../tutorial/datastructures.rst:612
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 ""
"Para percorrer uma sequncia de maneira ordenada, use a funo :func:"
"`sorted`, que retorna uma lista ordenada com os itens, mantendo a sequncia "
"original inalterada. ::"
#: ../../tutorial/datastructures.rst:626
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. ::"
msgstr ""
"Usar :func:`set` em uma sequncia elimina elementos duplicados. O uso de :"
"func:`sorted` em combinao com :func:`set` sobre uma sequncia uma "
"maneira idiomtica de fazer um loop sobre elementos exclusivos da sequncia "
"na ordem de classificao. ::"
#: ../../tutorial/datastructures.rst:639
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 ""
"s vezes tentador alterar uma lista enquanto voc itera sobre ela; porm, "
"costuma ser mais simples e seguro criar uma nova lista. ::"
#: ../../tutorial/datastructures.rst:656
msgid "More on Conditions"
msgstr "Mais sobre condies"
#: ../../tutorial/datastructures.rst:658
msgid ""
"The conditions used in ``while`` and ``if`` statements can contain any "
"operators, not just comparisons."
msgstr ""
"As condies de controle usadas nas instrues ``while`` e ``if`` podem "
"conter quaisquer operadores, no apenas comparaes."
#: ../../tutorial/datastructures.rst:662
msgid ""
"The comparison operators ``in`` and ``not in`` are membership tests that "
"determine whether a value is in (or not in) a container. The operators "
"``is`` and ``is not`` compare whether two objects are really the same "
"object. All comparison operators have the same priority, which is lower "
"than that of all numerical operators."
msgstr ""
"Os operadores de comparao ``in`` e ``not in`` fazem testes de incluso que "
"determinam se um valor est (ou no est) em um continer. Os operadores "
"``is`` e ``is not`` comparam se dois objetos so realmente o mesmo objeto. "
"Todos os operadores de comparao possuem a mesma prioridade, que menor "
"que a prioridade de todos os operadores numricos."
#: ../../tutorial/datastructures.rst:668
msgid ""
"Comparisons can be chained. For example, ``a < b == c`` tests whether ``a`` "
"is less than ``b`` and moreover ``b`` equals ``c``."
msgstr ""
"Comparaes podem ser encadeadas: Por exemplo ``a < b == c`` testa se ``a`` "
" menor que ``b`` e tambm se ``b`` igual a ``c``."
#: ../../tutorial/datastructures.rst:671
msgid ""
"Comparisons may be combined using the Boolean operators ``and`` and ``or``, "
"and the outcome of a comparison (or of any other Boolean expression) may be "
"negated with ``not``. These have lower priorities than comparison "
"operators; between them, ``not`` has the highest priority and ``or`` the "
"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 ""
"Comparaes podem ser combinadas atravs de operadores booleanos ``and`` e "
"``or``, e o resultado de uma comparao (ou de qualquer outra expresso), "
"pode ter seu valor booleano negado atravs de ``not``. Estes possuem menor "
"prioridade que os demais operadores de comparao. Entre eles, ``not`` o "
"de maior prioridade e ``or`` o de menor. Dessa forma, a condio ``A and not "
"B or C`` equivalente a ``(A and (not B)) or C``. Naturalmente, parnteses "
"podem ser usados para expressar o agrupamento desejado."
#: ../../tutorial/datastructures.rst:678
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 "
"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 ""
"Os operadores booleanos ``and`` e ``or`` so operadores *curto-circuito*: "
"seus argumentos so avaliados da esquerda para a direita, e a avaliao "
"encerra quando o resultado determinado. Por exemplo, se ``A`` e ``C`` so "
"expresses verdadeiras, mas ``B`` falsa, ento ``A and B and C`` no chega "
"a avaliar a expresso ``C``. Em geral, quando usado sobre valores genricos "
"e no como booleanos, o valor do resultado de um operador curto-circuito o "
"ltimo valor avaliado na expresso."
#: ../../tutorial/datastructures.rst:685
msgid ""
"It is possible to assign the result of a comparison or other Boolean "
"expression to a variable. For example, ::"
msgstr ""
" possvel atribuir o resultado de uma comparao ou outra expresso "
"booleana para uma varivel. Por exemplo::"
#: ../../tutorial/datastructures.rst:693
msgid ""
"Note that in Python, unlike C, assignment inside expressions must be done "
"explicitly with the :ref:`walrus operator ` ``:=``. This avoids a common class of problems encountered "
"in C programs: typing ``=`` in an expression when ``==`` was intended."
msgstr ""
"Observe que no Python, ao contrrio de C, a atribuio dentro de expresses "
"deve ser feita explicitamente com o :ref:`operador morsa ` ``:=``. Isso evita uma classe comum de "
"problemas encontrados nos programas C: digitar ``=`` em uma expresso quando "
"``==`` era o planejado."
#: ../../tutorial/datastructures.rst:703
msgid "Comparing Sequences and Other Types"
msgstr "Comparando sequncias e outros tipos"
#: ../../tutorial/datastructures.rst:704
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 "
"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 "
"sequences are considered equal. If one sequence is an initial sub-sequence "
"of the other, the shorter sequence is the smaller (lesser) one. "
"Lexicographical ordering for strings uses the Unicode code point number to "
"order individual characters. Some examples of comparisons between sequences "
"of the same type::"
msgstr ""
"Objetos sequncia podem ser comparados com outros objetos sequncia, desde "
"que o tipo das sequncias seja o mesmo. A comparao utiliza a ordem "
"lexicogrfica: primeiramente os dois primeiros itens so comparados, e se "
"diferirem isto determinar o resultado da comparao, caso contrrio os "
"prximos dois itens sero comparados, e assim por diante at que se tenha "
"exaurido alguma das sequncias. Se em uma comparao de itens, os mesmos "
"forem tambm sequncias (aninhadas), ento disparada recursivamente outra "
"comparao lexicogrfica. Se todos os itens da sequncia forem iguais, ento "
"as sequncias so ditas iguais. Se uma das sequncias uma subsequncia da "
"outra, ento a subsequncia a menor. A comparao lexicogrfica de strings "
"utiliza codificao Unicode para definir a ordenao. Alguns exemplos de "
"comparaes entre sequncias do mesmo tipo::"
#: ../../tutorial/datastructures.rst:724
msgid ""
"Note that comparing objects of different types with ```` is legal "
"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 ""
"Note que comparar objetos de tipos diferentes com ```` permitido "
"desde que os objetos possuam os mtodos de comparao apropriados. Por "
"exemplo, tipos numricos mistos so comparados de acordo com os seus valores "
"numricos, portanto 0 igual a 0.0, etc. Em caso contrrio, ao invs de "
"fornecer uma ordenao arbitrria, o interpretador levantar um :exc:"
"`TypeError`."
#: ../../tutorial/datastructures.rst:732
msgid "Footnotes"
msgstr "Notas de rodap"
#: ../../tutorial/datastructures.rst:733
msgid ""
"Other languages may return the mutated object, which allows method chaining, "
"such as ``d->insert(\"a\")->remove(\"b\")->sort();``."
msgstr ""
"Outras linguagens podem retornar o objeto modificado, o que permite "
"encadeamento de mtodos, como ``d->insert(\"a\")->remove(\"b\")->sort();``."