Skip to content

Commit b9c76f2

Browse files
committed
Translation of debugging chapter
1 parent 77de676 commit b9c76f2

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

debugging.rst

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
11
Debugging
22
---------
33

4-
Debugging is also something which once mastered can greatly enhance your
5-
bug hunting skills. Most of the newcomers neglect the importance of the
6-
Python debugger (``pdb``). In this section I am going to tell you only a
7-
few important commands. You can learn more about it from the official
8-
documentation.
4+
Debugging é algo que uma vez compreendido pode te ajudar enormemente
5+
em sua capacidade de encontrar erros (bugs). A maioria dos iniciantes
6+
negligencia a importancia do Python debugger (``pdb``). Nesta seção,
7+
eu vou mostrar alguns comandos importantes. Você pode aprender mais
8+
sobre isso a partir da documentação oficial.
99

10-
**Running from commandline**
10+
**Rodando a partir da linha de comando**
1111

12-
You can run a script from the commandline using the Python debugger.
13-
Here is an example:
12+
Quando você roda um script a partir da linha de comando usando um
13+
Python debugger. Aqui está um exemplo:
1414

1515
.. code:: python
1616
1717
$ python -m pdb my_script.py
1818
19-
It would cause the debugger to stop the execution on the first statement
20-
it finds. This is helpful if your script is short. You can then inspect
21-
the variables and continue execution line-by-line.
19+
Este comando faz com que o debuuger pare a execução do código na primeira
20+
linha de comando que ele encontrar. Isso é muito útil se o seu script for
21+
pequeno. Você pode inspecionar as variáveis e continuar a execução linha
22+
por linha.
2223

23-
**Running from inside a script**
24+
**Rodando de dentro de um script**
2425

25-
You can set break points in the script itself so that you can inspect
26-
the variables and stuff at particular points. This is possible using the
27-
``pdb.set_trace()`` method. Here is an example:
26+
Você pode inserir pontos de quebra (break points) dentro do próprio script
27+
para que você inspecione as variáveis e demais itens em pontos específicos do
28+
seu código. Isso é possível utilizando o método ``pdb.set_trace()``.
29+
Aqui está um exemplo:
2830

2931
.. code:: python
3032
3133
import pdb
3234
3335
def make_bread():
3436
pdb.set_trace()
35-
return "I don't have time"
37+
return "Eu não tenho tempo"
3638
3739
print(make_bread())
3840
39-
Try running the above script after saving it. You would enter the
40-
debugger as soon as you run it. Now it's time to learn some of the
41-
commands of the debugger.
41+
Tente rodar o script acima após salvá-lo. Você irá entrar no debugger
42+
assim que você o rodar. Agora é hora de aprender alguns dos comandos
43+
do debugger.
4244

43-
**Commands:**
45+
**Comandos:**
4446

45-
- ``c``: continue execution
46-
- ``w``: shows the context of the current line it is executing.
47-
- ``a``: print the argument list of the current function
48-
- ``s``: Execute the current line and stop at the first possible
49-
occasion.
50-
- ``n``: Continue execution until the next line in the current function
51-
is reached or it returns.
47+
- ``c``: continua a execução
48+
- ``w``: mostra o contexto da linha atual que ele estpa executando
49+
- ``a``: mostra a lista de argumentos da função atual
50+
- ``s``: executa a linha atual e para a execução assim que possível
51+
- ``n``: continua a execução até a próxima linha da função atual ou o seu retorno
5252

53-
The difference between ``n``\ ext and ``s``\ tep is that step stops
54-
inside a called function, while next executes called functions at
55-
(nearly) full speed, only stopping at the next line in the current
56-
function.
53+
A diferença entre ``n``\ ext e ``s``\ tep é que o método step para a execução
54+
dentro da função que foi chamada, enquanto o método next executa a função
55+
chanada em (quase) velocidade total, apenas parando na próxima linha da função
56+
onde o pdb foi inserido.
5757

58-
These are just a few commands. ``pdb`` also supports post mortem. It is
59-
also a really handy function. I would highly suggest you to look at the
60-
official documentation and learn more about it.
58+
Esses são apenas alguns comandos. ``pdb`` também suporta post mortem. Esta é
59+
realmente uma função muito útil. Eu também sugiro que você olhe a documentação
60+
oficial e aprenda mais sobre isso.

0 commit comments

Comments
 (0)