-
-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathextending.po
More file actions
472 lines (414 loc) · 19.6 KB
/
extending.po
File metadata and controls
472 lines (414 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# python-doc bot, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.9\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-22 21:56+0000\n"
"PO-Revision-Date: 2025-09-22 17:54+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"
#: ../../faq/extending.rst:3
msgid "Extending/Embedding FAQ"
msgstr "FAQ sobre Extensão/Incorporação"
#: ../../faq/extending.rst:6
msgid "Contents"
msgstr "Conteúdo"
#: ../../faq/extending.rst:16
msgid "Can I create my own functions in C?"
msgstr "Posso criar minhas próprias funções em C?"
#: ../../faq/extending.rst:18
msgid ""
"Yes, you can create built-in modules containing functions, variables, "
"exceptions and even new types in C. This is explained in the document :ref:"
"`extending-index`."
msgstr ""
"Sim, você pode construir módulos embutidos contendo funções, variáveis, "
"exceções e até mesmo novos tipos em C. Isso é explicado no documento :ref:"
"`extending-index`."
#: ../../faq/extending.rst:22
msgid "Most intermediate or advanced Python books will also cover this topic."
msgstr ""
"A maioria dos livros intermediários ou avançados em Python também abordará "
"esse tópico."
#: ../../faq/extending.rst:26
msgid "Can I create my own functions in C++?"
msgstr "Posso criar minhas próprias funções em C++?"
#: ../../faq/extending.rst:28
msgid ""
"Yes, using the C compatibility features found in C++. Place ``extern "
"\"C\" { ... }`` around the Python include files and put ``extern \"C\"`` "
"before each function that is going to be called by the Python interpreter. "
"Global or static C++ objects with constructors are probably not a good idea."
msgstr ""
"Sim, usando recursos de compatibilidade encontrados em C++. Coloque ``extern "
"\"C\" { ... }`` em torno dos arquivos de inclusão do Python e coloque "
"``extern \"C\"`` antes de cada função que será chamada pelo interpretador do "
"Python. Objetos globais ou estáticos em C++ com construtores provavelmente "
"não são uma boa ideia."
#: ../../faq/extending.rst:37
msgid "Writing C is hard; are there any alternatives?"
msgstr "Escrever C é difícil; há alguma alternativa?"
#: ../../faq/extending.rst:39
msgid ""
"There are a number of alternatives to writing your own C extensions, "
"depending on what you're trying to do."
msgstr ""
"Há um número de alternativas para escrever suas próprias extensões em C, "
"dependendo daquilo que você está tentando fazer."
#: ../../faq/extending.rst:44
msgid ""
"`Cython <http://cython.org>`_ and its relative `Pyrex <https://www.cosc."
"canterbury.ac.nz/greg.ewing/python/Pyrex/>`_ are compilers that accept a "
"slightly modified form of Python and generate the corresponding C code. "
"Cython and Pyrex make it possible to write an extension without having to "
"learn Python's C API."
msgstr ""
#: ../../faq/extending.rst:50
msgid ""
"If you need to interface to some C or C++ library for which no Python "
"extension currently exists, you can try wrapping the library's data types "
"and functions with a tool such as `SWIG <http://www.swig.org>`_. `SIP "
"<https://riverbankcomputing.com/software/sip/intro>`__, `CXX <http://cxx."
"sourceforge.net/>`_ `Boost <http://www.boost.org/libs/python/doc/index."
"html>`_, or `Weave <https://github.com/scipy/weave>`_ are also alternatives "
"for wrapping C++ libraries."
msgstr ""
#: ../../faq/extending.rst:61
msgid "How can I execute arbitrary Python statements from C?"
msgstr "Como posso executar instruções arbitrárias de Python a partir de C?"
#: ../../faq/extending.rst:63
msgid ""
"The highest-level function to do this is :c:func:`PyRun_SimpleString` which "
"takes a single string argument to be executed in the context of the module "
"``__main__`` and returns ``0`` for success and ``-1`` when an exception "
"occurred (including :exc:`SyntaxError`). If you want more control, use :c:"
"func:`PyRun_String`; see the source for :c:func:`PyRun_SimpleString` in "
"``Python/pythonrun.c``."
msgstr ""
"A função mais alto-nível para isso é a :c:func:`PyRun_SimpleString`, que "
"recebe como único argumento uma string a ser executada no contexto do módulo "
"``__main__`` e retorna ``0`` para sucesso e ``-1`` quando uma exceção "
"ocorrer (incluindo :exc:`SyntaxError`). Se quiser mais controle, use :c:"
"func:`PyRun_String`; veja o código-fonte de :c:func:`PyRun_SimpleString` em "
"``Python/pythonrun.c``."
#: ../../faq/extending.rst:72
msgid "How can I evaluate an arbitrary Python expression from C?"
msgstr ""
"Como posso executar e obter o resultado de uma expressão Python arbitrária a "
"partir de C?"
#: ../../faq/extending.rst:74
msgid ""
"Call the function :c:func:`PyRun_String` from the previous question with the "
"start symbol :c:data:`Py_eval_input`; it parses an expression, evaluates it "
"and returns its value."
msgstr ""
"Chame a função :c:func:`PyRun_String` da pergunta anterior passando :c:data:"
"`Py_eval_input` como o símbolo de início; ela faz a análise sintática de uma "
"expressão, a executa, e retorna o seu valor."
#: ../../faq/extending.rst:80
msgid "How do I extract C values from a Python object?"
msgstr "Como extraio valores em C a partir de um objeto Python?"
#: ../../faq/extending.rst:82
msgid ""
"That depends on the object's type. If it's a tuple, :c:func:`PyTuple_Size` "
"returns its length and :c:func:`PyTuple_GetItem` returns the item at a "
"specified index. Lists have similar functions, :c:func:`PyListSize` and :c:"
"func:`PyList_GetItem`."
msgstr ""
#: ../../faq/extending.rst:87
msgid ""
"For bytes, :c:func:`PyBytes_Size` returns its length and :c:func:"
"`PyBytes_AsStringAndSize` provides a pointer to its value and its length. "
"Note that Python bytes objects may contain null bytes so C's :c:func:"
"`strlen` should not be used."
msgstr ""
#: ../../faq/extending.rst:92
msgid ""
"To test the type of an object, first make sure it isn't ``NULL``, and then "
"use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:func:"
"`PyList_Check`, etc."
msgstr ""
"Para testar o tipo de um objeto, primeiramente se certifique de que ele não "
"é ``NULL``, e então use :c:func:`PyBytes_Check`, :c:func:`PyTuple_Check`, :c:"
"func:`PyList_Check`, etc."
#: ../../faq/extending.rst:95
msgid ""
"There is also a high-level API to Python objects which is provided by the so-"
"called 'abstract' interface -- read ``Include/abstract.h`` for further "
"details. It allows interfacing with any kind of Python sequence using calls "
"like :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc. as well "
"as many other useful protocols such as numbers (:c:func:`PyNumber_Index` et "
"al.) and mappings in the PyMapping APIs."
msgstr ""
"Também existe uma API alto-nível para objetos Python fornecida pela chamada "
"interface \"abstrata\" -- leia ``Include/abstract.h`` para mais detalhes. "
"Ela permite interagir com qualquer tipo de sequência Python usando chamadas "
"como :c:func:`PySequence_Length`, :c:func:`PySequence_GetItem`, etc, além de "
"vários outros protocolos úteis tais como números (:c:func:`PyNumber_Index` e "
"outros) e mapeamentos nas APIs PyMapping."
#: ../../faq/extending.rst:104
msgid "How do I use Py_BuildValue() to create a tuple of arbitrary length?"
msgstr ""
"Como posso utilizar Py_BuildValue() para criar uma tupla de comprimento "
"arbitrário?"
#: ../../faq/extending.rst:106
msgid "You can't. Use :c:func:`PyTuple_Pack` instead."
msgstr "Não é possível. Use a função :c:func:`PyTuple_Pack` para isso."
#: ../../faq/extending.rst:110
msgid "How do I call an object's method from C?"
msgstr "Como eu chamo um método de um objeto a partir do C?"
#: ../../faq/extending.rst:112
msgid ""
"The :c:func:`PyObject_CallMethod` function can be used to call an arbitrary "
"method of an object. The parameters are the object, the name of the method "
"to call, a format string like that used with :c:func:`Py_BuildValue`, and "
"the argument values::"
msgstr ""
"A função :c:func:`PyObject_CallMethod` pode ser usada para chamar um método "
"arbitrário de um objeto. Os parâmetros são o objeto, o nome do método a ser "
"chamado, uma string de formato como a usada em :c:func:`Py_BuildValue`, e os "
"valores dos argumentos::"
#: ../../faq/extending.rst:121
msgid ""
"This works for any object that has methods -- whether built-in or user-"
"defined. You are responsible for eventually :c:func:`Py_DECREF`\\ 'ing the "
"return value."
msgstr ""
"Isso funciona para qualquer objeto que tenha métodos -- sejam eles embutidos "
"ou definidos por usuário. Você fica então responsável por chamar :c:func:"
"`Py_DECREF` no valor de retorno."
#: ../../faq/extending.rst:124
msgid ""
"To call, e.g., a file object's \"seek\" method with arguments 10, 0 "
"(assuming the file object pointer is \"f\")::"
msgstr ""
"Para chamar, por exemplo, o método \"seek\" de um objeto arquivo com "
"argumentos 10, 0 (presumindo que \"f\" é o ponteiro para o objeto arquivo)::"
#: ../../faq/extending.rst:135
msgid ""
"Note that since :c:func:`PyObject_CallObject` *always* wants a tuple for the "
"argument list, to call a function without arguments, pass \"()\" for the "
"format, and to call a function with one argument, surround the argument in "
"parentheses, e.g. \"(i)\"."
msgstr ""
"Note que a função :c:func:`PyObject_CallObject` *sempre* recebe os "
"argumentos da chamada como uma tupla, de forma que para chamar uma função "
"sem argumentos deve-se passar \"()\" como formato, e para chamar uma função "
"com 1 argumento, coloque-o entre parênteses, por exemplo \"(i)\"."
#: ../../faq/extending.rst:142
msgid ""
"How do I catch the output from PyErr_Print() (or anything that prints to "
"stdout/stderr)?"
msgstr ""
"Como posso capturar a saída da função PyErr_Print() (ou qualquer outra coisa "
"que escreva para stdout/stderr)?"
#: ../../faq/extending.rst:144
msgid ""
"In Python code, define an object that supports the ``write()`` method. "
"Assign this object to :data:`sys.stdout` and :data:`sys.stderr`. Call "
"print_error, or just allow the standard traceback mechanism to work. Then, "
"the output will go wherever your ``write()`` method sends it."
msgstr ""
"Com código Python, defina um objeto que suporte o método ``write()``. "
"Atribua esse objeto a :data:`sys.stdout` e :data:`sys.stderr`. Chame "
"print_error, or simplesmente deixe o mecanismo padrão de traceback "
"acontecer. Assim, a saída irá para onde quer que o seu método ``write()`` a "
"envie."
#: ../../faq/extending.rst:149
msgid "The easiest way to do this is to use the :class:`io.StringIO` class:"
msgstr "O jeito mais fácil de fazer isso é usar a classe :class:`io.StringIO`:"
#: ../../faq/extending.rst:161
msgid "A custom object to do the same would look like this:"
msgstr "Um objeto personalizado para fazer a mesma coisa seria esse:"
#: ../../faq/extending.rst:182
msgid "How do I access a module written in Python from C?"
msgstr "Como faço para acessar a partir do C um módulo escrito em Python?"
#: ../../faq/extending.rst:184
msgid "You can get a pointer to the module object as follows::"
msgstr ""
"Você pode obter um pointeiro para o objeto de módulo da seguinte maneira::"
#: ../../faq/extending.rst:188
msgid ""
"If the module hasn't been imported yet (i.e. it is not yet present in :data:"
"`sys.modules`), this initializes the module; otherwise it simply returns the "
"value of ``sys.modules[\"<modulename>\"]``. Note that it doesn't enter the "
"module into any namespace -- it only ensures it has been initialized and is "
"stored in :data:`sys.modules`."
msgstr ""
"Se o módulo ainda não foi importado (isto é, ainda não aparece no :data:`sys."
"modules`), essa função vai inicializar o módulo; caso contrário, ela vai "
"simplesmente retornar o valor de ``sys.modules[\"<modulename>\"]``. Note "
"que ela não adiciona o módulo a nenhum espaço de nomes -- ela simplesmente "
"garante que ele foi inicializado e colocado no :data:`sys.modules`."
#: ../../faq/extending.rst:194
msgid ""
"You can then access the module's attributes (i.e. any name defined in the "
"module) as follows::"
msgstr ""
"Você pode então acessar os atributos do módulo (isto é, qualquer nome "
"definido no módulo) assim::"
#: ../../faq/extending.rst:199
msgid ""
"Calling :c:func:`PyObject_SetAttrString` to assign to variables in the "
"module also works."
msgstr ""
"Chamar :c:func:`PyObject_SetAttrString` para definir variáveis no módulo "
"também funciona."
#: ../../faq/extending.rst:204
msgid "How do I interface to C++ objects from Python?"
msgstr "Como posso interagir com objetos C++ a partir do Python?"
#: ../../faq/extending.rst:206
msgid ""
"Depending on your requirements, there are many approaches. To do this "
"manually, begin by reading :ref:`the \"Extending and Embedding\" document "
"<extending-index>`. Realize that for the Python run-time system, there "
"isn't a whole lot of difference between C and C++ -- so the strategy of "
"building a new Python type around a C structure (pointer) type will also "
"work for C++ objects."
msgstr ""
"Dependendo das suas necessidades, há diversas abordagens. Para fazer isso "
"manualmente, comece lendo :ref:`o documento \"Estendendo e Incorporando\" "
"<extending-index>`. Note que, para o sistema Python em tempo de execução, "
"não há muita diferença entre C e C++ -- de forma que a estratégia de "
"construir um novo tipo Python ao redor de uma estrutura C (ou ponteiro para "
"uma) também funciona para objetos C++."
#: ../../faq/extending.rst:212
msgid "For C++ libraries, see :ref:`c-wrapper-software`."
msgstr "Para bibliotecas C++, veja :ref:`c-wrapper-software`."
#: ../../faq/extending.rst:216
msgid "I added a module using the Setup file and the make fails; why?"
msgstr "Adicionei um módulo usando o arquivo de Setup e o make falha; por quê?"
#: ../../faq/extending.rst:218
msgid ""
"Setup must end in a newline, if there is no newline there, the build process "
"fails. (Fixing this requires some ugly shell script hackery, and this bug "
"is so minor that it doesn't seem worth the effort.)"
msgstr ""
"O Setup deve terminar com uma quebra de linha; se não houver uma quebra de "
"linha no final, o processo de compilação falha. (Consertar isso requer umas "
"gambiarras feias em shell script, e esse bug é tão pequeno que o esforço não "
"parece valer a pena.)"
#: ../../faq/extending.rst:224
msgid "How do I debug an extension?"
msgstr "Como eu depuro uma extensão?"
#: ../../faq/extending.rst:226
msgid ""
"When using GDB with dynamically loaded extensions, you can't set a "
"breakpoint in your extension until your extension is loaded."
msgstr ""
"Ao usar o GDB com extensões carregadas dinamicamente, você não consegue "
"definir um ponto de interrupção antes da sua extensão ser carregada."
#: ../../faq/extending.rst:229
msgid "In your ``.gdbinit`` file (or interactively), add the command:"
msgstr ""
"No seu arquivo ``.gdbinit`` (ou então interativamente), adicione o comando:"
#: ../../faq/extending.rst:235
msgid "Then, when you run GDB:"
msgstr "Então, ao executar o GDB:"
#: ../../faq/extending.rst:247
msgid ""
"I want to compile a Python module on my Linux system, but some files are "
"missing. Why?"
msgstr ""
"Quero compilar um módulo Python no meu sistema Linux, mas alguns arquivos "
"estão faltando. Por quê?"
#: ../../faq/extending.rst:249
msgid ""
"Most packaged versions of Python don't include the :file:`/usr/lib/python2."
"{x}/config/` directory, which contains various files required for compiling "
"Python extensions."
msgstr ""
#: ../../faq/extending.rst:253
msgid "For Red Hat, install the python-devel RPM to get the necessary files."
msgstr ""
#: ../../faq/extending.rst:255
msgid "For Debian, run ``apt-get install python-dev``."
msgstr ""
#: ../../faq/extending.rst:258
msgid "How do I tell \"incomplete input\" from \"invalid input\"?"
msgstr "Como posso distinguir \"entrada incompleta\" de \"entrada inválida\"?"
#: ../../faq/extending.rst:260
msgid ""
"Sometimes you want to emulate the Python interactive interpreter's behavior, "
"where it gives you a continuation prompt when the input is incomplete (e.g. "
"you typed the start of an \"if\" statement or you didn't close your "
"parentheses or triple string quotes), but it gives you a syntax error "
"message immediately when the input is invalid."
msgstr ""
"Às vezes você quer emular o comportamento do interpretador interativo do "
"Python, que te dá um prompt de continuação quando a entrada está incompleta "
"(por exemplo, você digitou o início de uma instrução \"if\", ou então não "
"fechou os parênteses ou aspas triplas), mas que te dá um mensagem de erro de "
"sintaxe imediatamente se a entrada for inválida."
#: ../../faq/extending.rst:266
msgid ""
"In Python you can use the :mod:`codeop` module, which approximates the "
"parser's behavior sufficiently. IDLE uses this, for example."
msgstr ""
"Em Python você pode usar o módulo :mod:`codeop`, que aproxima "
"suficientemente o comportamento do analisador sintático. Por exemplo, o "
"IDLE o usa."
#: ../../faq/extending.rst:269
msgid ""
"The easiest way to do it in C is to call :c:func:`PyRun_InteractiveLoop` "
"(perhaps in a separate thread) and let the Python interpreter handle the "
"input for you. You can also set the :c:func:`PyOS_ReadlineFunctionPointer` "
"to point at your custom input function. See ``Modules/readline.c`` and "
"``Parser/myreadline.c`` for more hints."
msgstr ""
"Em C, a forma mais fácil de fazer isso é chamar :c:func:"
"`PyRun_InteractiveLoop` (talvez em uma thread separada) e deixar o "
"interpretador do Python tratar a entrada para você. Você também pode apontar "
"o :c:func:`PyOS_ReadlineFunctionPointer` para a sua função de entrada "
"personalizada. Consulte ``Modules/readline.c`` e ``Parser/myreadline.c`` "
"para mais dicas."
#: ../../faq/extending.rst:276
msgid "How do I find undefined g++ symbols __builtin_new or __pure_virtual?"
msgstr ""
"Como encontro os símbolos __builtin_new ou __pure_virtual não-definidos no g+"
"+?"
#: ../../faq/extending.rst:278
msgid ""
"To dynamically load g++ extension modules, you must recompile Python, relink "
"it using g++ (change LINKCC in the Python Modules Makefile), and link your "
"extension module using g++ (e.g., ``g++ -shared -o mymodule.so mymodule.o``)."
msgstr ""
"Para carregar dinamicamente módulos de extensão feitos com g++, você precisa "
"recompilar o Python, usando o g++ como ligador (mude a constante LINKCC no "
"Makefile dos módulos de extensão do Python), e use o g++ também como ligador "
"do seu módulo (por exemplo, ``g++ -shared -o mymodule.so mymodule.o``)."
#: ../../faq/extending.rst:284
msgid ""
"Can I create an object class with some methods implemented in C and others "
"in Python (e.g. through inheritance)?"
msgstr ""
"Posso criar uma classe de objetos com alguns métodos implementados em C e "
"outros em Python (por exemplo, via herança)?"
#: ../../faq/extending.rst:286
msgid ""
"Yes, you can inherit from built-in classes such as :class:`int`, :class:"
"`list`, :class:`dict`, etc."
msgstr ""
"Sim, você pode herdar de classes embutidas como :class:`int`, :class:"
"`list`, :class:`dict` etc."
#: ../../faq/extending.rst:289
msgid ""
"The Boost Python Library (BPL, http://www.boost.org/libs/python/doc/index."
"html) provides a way of doing this from C++ (i.e. you can inherit from an "
"extension class written in C++ using the BPL)."
msgstr ""