portugython 0.4.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {portugython-0.4.0 → portugython-0.4.1}/CHANGELOG.md +49 -42
- {portugython-0.4.0 → portugython-0.4.1}/PKG-INFO +39 -39
- {portugython-0.4.0 → portugython-0.4.1}/README.md +38 -38
- {portugython-0.4.0 → portugython-0.4.1}/portugython/__init__.py +4 -4
- {portugython-0.4.0 → portugython-0.4.1}/portugython/_importador.py +16 -16
- {portugython-0.4.0 → portugython-0.4.1}/portugython/transpilador.py +22 -22
- {portugython-0.4.0 → portugython-0.4.1}/pyproject.toml +1 -1
- {portugython-0.4.0 → portugython-0.4.1}/tests/test_portugython.py +1 -1
- {portugython-0.4.0 → portugython-0.4.1}/.gitignore +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/LICENSE +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/abstrato.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/aleatorio.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/argumentos.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/assincronico.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/bisecao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/calendario.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/caminho.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/classe_dados.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/codificacao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/colecoes.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/compressao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/configuracao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/contexto.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/copia.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/csv_pt.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/depuracao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/enumeracao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/estatistica.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/estrutura.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/expressao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/formatacao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/funcional.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/hash_pt.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/identificador.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/iteradores.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/json.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/matematica.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/py.typed +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/rede.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/registro.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/serializacao.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/sistema.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/soquete.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/subprocesso.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/tempo.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/threads.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/portugython/tipagem.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/tests/__init__.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/tests/ola_mundo.ptpy +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/tests/test_importador.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/tests/test_submodulos.py +0 -0
- {portugython-0.4.0 → portugython-0.4.1}/tests/test_transpilador.py +0 -0
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.4.
|
|
3
|
+
## 0.4.1 (2026-06-26)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Corrige acentuação em toda a documentação (README, CHANGELOG, docstrings).
|
|
6
|
+
Sem alterações na API ou no código.
|
|
7
7
|
|
|
8
|
-
New module `portugython.transpilador`:
|
|
9
8
|
|
|
10
|
-
- `traduzir(codigo)` - translates Portuguese Python source to valid Python
|
|
11
|
-
- `traduzir_para_portugues(codigo)` - inverse translation
|
|
12
|
-
- `executar_texto(codigo)` - translate and execute a Portuguese Python string
|
|
13
|
-
- `executar_arquivo(caminho)` - translate and execute a `.ptpy` file
|
|
14
|
-
- `mostrar_traducao(codigo)` - print the translated Python source
|
|
15
|
-
- `MAPA_PALAVRAS_CHAVE` - full keyword translation table
|
|
16
|
-
- `PALAVRAS_RESERVADAS` - frozenset of reserved Portuguese keywords
|
|
17
9
|
|
|
18
|
-
|
|
10
|
+
Adiciona módulo `transpilador`: transpilador de código-fonte baseado no tokenizador do
|
|
11
|
+
Python que traduz palavras-chave para português, permitindo sintaxe Python completamente
|
|
12
|
+
em português.
|
|
13
|
+
|
|
14
|
+
Novo módulo `portugython.transpilador`:
|
|
15
|
+
|
|
16
|
+
- `traduzir(codigo)` - traduz código Python em português para Python padrão
|
|
17
|
+
- `traduzir_para_portugues(codigo)` - tradução inversa
|
|
18
|
+
- `executar_texto(codigo)` - traduz e executa uma string de código em português
|
|
19
|
+
- `executar_arquivo(caminho)` - traduz e executa um arquivo `.ptpy`
|
|
20
|
+
- `mostrar_traducao(codigo)` - imprime o código Python equivalente
|
|
21
|
+
- `MAPA_PALAVRAS_CHAVE` - tabela completa de tradução de palavras-chave
|
|
22
|
+
- `PALAVRAS_RESERVADAS` - frozenset de palavras-chave reservadas em português
|
|
23
|
+
|
|
24
|
+
Traduções de palavras-chave (34 palavras):
|
|
19
25
|
|
|
20
26
|
se -> if senaose -> elif senao -> else
|
|
21
27
|
para -> for enquanto -> while parar -> break
|
|
@@ -32,15 +38,15 @@ Keyword translations (34 keywords):
|
|
|
32
38
|
assincronico -> async aguardar -> await
|
|
33
39
|
Verdadeiro -> True Falso -> False Nenhum -> None
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
Novo ponto de entrada CLI: `ptpy` executa arquivos `.ptpy` diretamente:
|
|
36
42
|
|
|
37
43
|
ptpy meu_programa.ptpy
|
|
38
44
|
ptpy -c 'para i em intervalo(3): escreva(i)'
|
|
39
|
-
ptpy --mostrar meu_programa.ptpy #
|
|
45
|
+
ptpy --mostrar meu_programa.ptpy # exibe o Python equivalente
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
Hook de importação estendido para carregar arquivos `.ptpy` pelo sistema de importação normal.
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
Exemplo de programa `.ptpy`:
|
|
44
50
|
|
|
45
51
|
```python
|
|
46
52
|
defina fatorial(n):
|
|
@@ -53,11 +59,12 @@ para i em intervalo(1, 6):
|
|
|
53
59
|
escreva(f"{i}! = {fatorial(i)}")
|
|
54
60
|
```
|
|
55
61
|
|
|
62
|
+
## 0.3.0 (2026-06-26)
|
|
56
63
|
|
|
64
|
+
Adiciona hook de importação para que todos os módulos em português funcionem como
|
|
65
|
+
importações de nível superior.
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
After `import portugython`, the full stdlib-level syntax works:
|
|
67
|
+
Após `import portugython`, a sintaxe completa em nível de stdlib funciona:
|
|
61
68
|
|
|
62
69
|
import aleatorio
|
|
63
70
|
from matematica import raiz_quadrada, PI
|
|
@@ -67,25 +74,26 @@ After `import portugython`, the full stdlib-level syntax works:
|
|
|
67
74
|
from dados import serializar, deserializar # json
|
|
68
75
|
from subprocesso import executar
|
|
69
76
|
from caminho import Caminho
|
|
70
|
-
# ...
|
|
77
|
+
# ... todos os 36 módulos
|
|
71
78
|
|
|
72
|
-
|
|
79
|
+
Novos exports:
|
|
73
80
|
- `portugython.instalar()` - instala o gancho (chamado automaticamente)
|
|
74
81
|
- `portugython.desinstalar()` - remove o gancho
|
|
75
82
|
- `portugython.listar_modulos()` - retorna o mapa de nomes
|
|
76
83
|
|
|
84
|
+
## 0.2.0 (2026-06-26)
|
|
77
85
|
|
|
86
|
+
Cobertura completa da stdlib. 36 submódulos no total, todos importáveis via
|
|
87
|
+
`from portugython import <modulo>`:
|
|
78
88
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
**New in 0.2.0:**
|
|
89
|
+
**Novos em 0.2.0:**
|
|
82
90
|
- `caminho` (pathlib): Caminho com existe, eh_arquivo, listar, ler_texto, escrever_texto, etc.
|
|
83
91
|
- `json`: serializar, deserializar, serializar_arquivo, deserializar_arquivo
|
|
84
92
|
- `estatistica` (statistics): media, mediana, moda, desvio_padrao, covariancia, correlacao, quantis
|
|
85
93
|
- `enumeracao` (enum): Enumeracao, EnumeracaoInteira, EnumeracaoBandeira, automatico, unico
|
|
86
94
|
- `classe_dados` (dataclasses): classe_dados, campo, para_dicionario, para_tupla, substituir
|
|
87
95
|
- `contexto` (contextlib): gerenciador, suprimir, fechar_ao_sair, pilha_saida
|
|
88
|
-
- `tipagem` (typing): re-exporta todos os tipos com nomes em
|
|
96
|
+
- `tipagem` (typing): re-exporta todos os tipos com nomes em português
|
|
89
97
|
- `csv_pt` (csv): ler_csv, escrever_csv, LeitorCSV, EscritorCSV, LeitorDicionario
|
|
90
98
|
- `registro` (logging): obter_registrador, configurar_registro, depurar, informar, avisar, erro
|
|
91
99
|
- `argumentos` (argparse): AnalisadorArgumentos com adicionar_argumento, analisar
|
|
@@ -108,14 +116,13 @@ Full stdlib coverage. 36 submodules total, all importable via `from portugython
|
|
|
108
116
|
- `estrutura` (struct): empacotar, desempacotar, calcular_tamanho
|
|
109
117
|
- `rede` (urllib + http): baixar_url, abrir_url, analisar_url, codificar_url, codificar_parametros
|
|
110
118
|
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
- 49
|
|
114
|
-
|
|
119
|
+
Também em 0.2.0:
|
|
120
|
+
- Correção: alias de builtin `identificador` renomeado para `obter_id` para evitar shadowing do submódulo uuid
|
|
121
|
+
- 49 testes cobrindo todos os módulos
|
|
115
122
|
|
|
116
123
|
## 0.1.0 (2026-06-26)
|
|
117
124
|
|
|
118
|
-
-
|
|
125
|
+
- Adiciona conjunto completo de submódulos da stdlib com traduções em português:
|
|
119
126
|
- `aleatorio` (random): escolha, embaralhe, amostra, gauss, normal, etc.
|
|
120
127
|
- `matematica` (math): raiz_quadrada, seno, cosseno, fatorial, mdc, mmc, etc.
|
|
121
128
|
- `sistema` (os + sys): diretorio_atual, listar_diretorio, existe, sair, etc.
|
|
@@ -124,21 +131,21 @@ Also in 0.2.0:
|
|
|
124
131
|
- `iteradores` (itertools): encadeie, combine, permute, acumule, agrupe, etc.
|
|
125
132
|
- `funcional` (functools): reduzido, parcial, cache, compor, negado, etc.
|
|
126
133
|
- `expressao` (re): compilar, buscar, substituir, encontrar_todos, Padrao, etc.
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
131
|
-
-
|
|
132
|
-
- 30
|
|
134
|
+
- Reescrita do `__init__.py` com nomes em português limpos (remove sufixos `_pt`)
|
|
135
|
+
- Adiciona classe `Conjunto` com métodos em português
|
|
136
|
+
- Expande `Texto`, `Lista`, `Dicionario` com mais métodos
|
|
137
|
+
- Adiciona mais tipos de exceção: ErroArquivo, ErroPermissao, ErroRecursao, ErroPausa
|
|
138
|
+
- Versão mínima do Python elevada para >=3.10
|
|
139
|
+
- 30 testes cobrindo todos os módulos
|
|
133
140
|
|
|
134
141
|
## 0.0.15 (2026-06-26)
|
|
135
142
|
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
143
|
+
- Adiciona traduções em português dos builtins e funções principais do Python
|
|
144
|
+
- Introduz classes Lista, Dicionario, Texto com métodos em português
|
|
145
|
+
- Adiciona funções auxiliares: se(), para_cada(), filtro()
|
|
146
|
+
- Adiciona classes de exceção em português
|
|
147
|
+
- Expande a suíte de testes
|
|
141
148
|
|
|
142
149
|
## 0.0.14 (2022-11-28)
|
|
143
150
|
|
|
144
|
-
-
|
|
151
|
+
- Última versão anterior no PyPI.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: portugython
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: A Portuguese translation of Python: functions, modules and syntax
|
|
5
5
|
Project-URL: Homepage, https://github.com/spacemany2k38/portugython
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/spacemany2k38/portugython/issues
|
|
@@ -31,22 +31,22 @@ Description-Content-Type: text/markdown
|
|
|
31
31
|
[](https://pypi.org/project/portugython/)
|
|
32
32
|
[](https://opensource.org/licenses/MIT)
|
|
33
33
|
|
|
34
|
-
Escreva Python em
|
|
34
|
+
Escreva Python em Português. Portugython traduz funções, tipos e módulos da biblioteca padrão do Python para nomes em português.
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## Instalação
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
39
|
pip install portugython
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
## Uso
|
|
42
|
+
## Uso básico
|
|
43
43
|
|
|
44
44
|
```python
|
|
45
45
|
from portugython import *
|
|
46
46
|
|
|
47
|
-
escreva("
|
|
48
|
-
nome = leia("Qual
|
|
49
|
-
escreva("
|
|
47
|
+
escreva("Olá, Mundo!")
|
|
48
|
+
nome = leia("Qual é seu nome? ")
|
|
49
|
+
escreva("Olá,", nome)
|
|
50
50
|
|
|
51
51
|
numeros = Lista([1, 2, 3, 4, 5])
|
|
52
52
|
numeros.adicione(6)
|
|
@@ -60,9 +60,9 @@ resultado = se(tamanho(pares) > 0, "tem pares", "sem pares")
|
|
|
60
60
|
escreva(resultado)
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
##
|
|
63
|
+
## Módulos da biblioteca padrão
|
|
64
64
|
|
|
65
|
-
Cada
|
|
65
|
+
Cada módulo da stdlib tem uma versão em português que pode ser importada separadamente.
|
|
66
66
|
|
|
67
67
|
### aleatorio (random)
|
|
68
68
|
|
|
@@ -159,7 +159,7 @@ print(p.x, p.y)
|
|
|
159
159
|
```python
|
|
160
160
|
from portugython import iteradores
|
|
161
161
|
|
|
162
|
-
#
|
|
162
|
+
# Combinatória
|
|
163
163
|
for combo in iteradores.combine([1, 2, 3, 4], 2):
|
|
164
164
|
print(combo)
|
|
165
165
|
|
|
@@ -167,7 +167,7 @@ for combo in iteradores.combine([1, 2, 3, 4], 2):
|
|
|
167
167
|
for par in iteradores.produto("AB", "12"):
|
|
168
168
|
print(par)
|
|
169
169
|
|
|
170
|
-
#
|
|
170
|
+
# Acumulação
|
|
171
171
|
totais = list(iteradores.acumule([1, 2, 3, 4, 5]))
|
|
172
172
|
|
|
173
173
|
# Encadeamento
|
|
@@ -179,21 +179,21 @@ unido = list(iteradores.encadeie([1, 2], [3, 4], [5]))
|
|
|
179
179
|
```python
|
|
180
180
|
from portugython import funcional
|
|
181
181
|
|
|
182
|
-
#
|
|
182
|
+
# Redução
|
|
183
183
|
total = funcional.reduzido(lambda a, b: a + b, range(1, 11))
|
|
184
184
|
|
|
185
|
-
#
|
|
185
|
+
# Função parcial
|
|
186
186
|
multiplicar_por_3 = funcional.parcial(lambda a, b: a * b, 3)
|
|
187
187
|
print(multiplicar_por_3(7))
|
|
188
188
|
|
|
189
|
-
#
|
|
189
|
+
# Memoização
|
|
190
190
|
@funcional.cache
|
|
191
191
|
def fibonacci(n):
|
|
192
192
|
if n < 2:
|
|
193
193
|
return n
|
|
194
194
|
return fibonacci(n - 1) + fibonacci(n - 2)
|
|
195
195
|
|
|
196
|
-
#
|
|
196
|
+
# Composição
|
|
197
197
|
dobrar = lambda x: x * 2
|
|
198
198
|
somar_um = lambda x: x + 1
|
|
199
199
|
dobrar_e_somar = funcional.compor(somar_um, dobrar)
|
|
@@ -213,26 +213,26 @@ if m:
|
|
|
213
213
|
# Todos os resultados
|
|
214
214
|
numeros = expressao.encontrar_todos(r"\d+", "1 mais 2 igual 3")
|
|
215
215
|
|
|
216
|
-
#
|
|
216
|
+
# Substituição
|
|
217
217
|
limpo = expressao.substituir(r"\s+", " ", "texto com espacos")
|
|
218
218
|
|
|
219
|
-
#
|
|
219
|
+
# Padrão reutilizável
|
|
220
220
|
email = expressao.Padrao(r"[\w.+-]+@[\w-]+\.[a-z]{2,}")
|
|
221
221
|
if email.encontrar("contato@example.com"):
|
|
222
|
-
print("
|
|
222
|
+
print("E-mail válido")
|
|
223
223
|
```
|
|
224
224
|
|
|
225
|
-
##
|
|
225
|
+
## Referência de builtins
|
|
226
226
|
|
|
227
|
-
### Entrada /
|
|
228
|
-
|
|
|
227
|
+
### Entrada / Saída
|
|
228
|
+
| Português | Python |
|
|
229
229
|
|-----------|--------|
|
|
230
230
|
| `escreva` | `print` |
|
|
231
231
|
| `leia` | `input` |
|
|
232
232
|
| `abra` | `open` |
|
|
233
233
|
|
|
234
234
|
### Tipos
|
|
235
|
-
|
|
|
235
|
+
| Português | Python |
|
|
236
236
|
|-----------|--------|
|
|
237
237
|
| `inteiro` | `int` |
|
|
238
238
|
| `texto` | `str` |
|
|
@@ -245,14 +245,14 @@ if email.encontrar("contato@example.com"):
|
|
|
245
245
|
| `intervalo` | `range` |
|
|
246
246
|
|
|
247
247
|
### Constantes
|
|
248
|
-
|
|
|
248
|
+
| Português | Python |
|
|
249
249
|
|-----------|--------|
|
|
250
250
|
| `Verdadeiro` | `True` |
|
|
251
251
|
| `Falso` | `False` |
|
|
252
252
|
| `Nenhum` | `None` |
|
|
253
253
|
|
|
254
|
-
###
|
|
255
|
-
|
|
|
254
|
+
### Funções de sequência
|
|
255
|
+
| Português | Python |
|
|
256
256
|
|-----------|--------|
|
|
257
257
|
| `tamanho` | `len` |
|
|
258
258
|
| `soma` | `sum` |
|
|
@@ -266,15 +266,15 @@ if email.encontrar("contato@example.com"):
|
|
|
266
266
|
| `mapeado` | `map` |
|
|
267
267
|
| `filtrado` | `filter` |
|
|
268
268
|
|
|
269
|
-
### Operadores
|
|
270
|
-
|
|
|
269
|
+
### Operadores lógicos
|
|
270
|
+
| Português | Python |
|
|
271
271
|
|-----------|--------|
|
|
272
272
|
| `nao(x)` | `not x` |
|
|
273
273
|
| `e(a, b)` | `a and b` |
|
|
274
274
|
| `ou(a, b)` | `a or b` |
|
|
275
275
|
|
|
276
|
-
###
|
|
277
|
-
|
|
|
276
|
+
### Funções utilitárias
|
|
277
|
+
| Português | Python |
|
|
278
278
|
|-----------|--------|
|
|
279
279
|
| `se(c, a, b)` | `a if c else b` |
|
|
280
280
|
| `para_cada(f, it)` | `list(map(f, it))` |
|
|
@@ -284,8 +284,8 @@ if email.encontrar("contato@example.com"):
|
|
|
284
284
|
## Transpilador de palavras-chave
|
|
285
285
|
|
|
286
286
|
Portugython inclui um transpilador completo que traduz a sintaxe do Python
|
|
287
|
-
(palavras-chave) para
|
|
288
|
-
inteiramente em
|
|
287
|
+
(palavras-chave) para português. Isso permite escrever programas Python
|
|
288
|
+
inteiramente em português.
|
|
289
289
|
|
|
290
290
|
### CLI: ptpy
|
|
291
291
|
|
|
@@ -322,7 +322,7 @@ executar_texto("para i em intervalo(3):\n escreva(i)")
|
|
|
322
322
|
executar_arquivo("meu_programa.ptpy")
|
|
323
323
|
```
|
|
324
324
|
|
|
325
|
-
### Programa completo em
|
|
325
|
+
### Programa completo em português (.ptpy)
|
|
326
326
|
|
|
327
327
|
```python
|
|
328
328
|
# fatorial.ptpy
|
|
@@ -358,7 +358,7 @@ finalmente:
|
|
|
358
358
|
|
|
359
359
|
### Tabela de palavras-chave
|
|
360
360
|
|
|
361
|
-
|
|
|
361
|
+
| Português | Python | | Português | Python |
|
|
362
362
|
|-----------|--------|-|-----------|--------|
|
|
363
363
|
| `se` | `if` | | `senao` | `else` |
|
|
364
364
|
| `senaose` | `elif` | | `para` | `for` |
|
|
@@ -379,17 +379,17 @@ finalmente:
|
|
|
379
379
|
| `Verdadeiro` | `True` | | `Falso` | `False` |
|
|
380
380
|
| `Nenhum` | `None` | | | |
|
|
381
381
|
|
|
382
|
-
> **Nota**: Palavras como `e`, `ou`, `de`, `com` e `em`
|
|
383
|
-
> reservadas no contexto de arquivos `.ptpy`. Evite
|
|
384
|
-
>
|
|
385
|
-
>
|
|
382
|
+
> **Nota**: Palavras como `e`, `ou`, `de`, `com` e `em` são palavras-chave
|
|
383
|
+
> reservadas no contexto de arquivos `.ptpy`. Evite usá-las como nomes de
|
|
384
|
+
> variáveis nesses arquivos, assim como não se usa `if` ou `for` como
|
|
385
|
+
> variáveis em Python normal.
|
|
386
386
|
|
|
387
387
|
## Contribuir
|
|
388
388
|
|
|
389
|
-
1. Crie um fork deste
|
|
389
|
+
1. Crie um fork deste repositório
|
|
390
390
|
2. Crie uma branch nova a partir de main
|
|
391
391
|
3. Envie um pull request
|
|
392
392
|
|
|
393
|
-
##
|
|
393
|
+
## Licença
|
|
394
394
|
|
|
395
395
|
MIT
|
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
[](https://pypi.org/project/portugython/)
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
|
|
7
|
-
Escreva Python em
|
|
7
|
+
Escreva Python em Português. Portugython traduz funções, tipos e módulos da biblioteca padrão do Python para nomes em português.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Instalação
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
pip install portugython
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
## Uso
|
|
15
|
+
## Uso básico
|
|
16
16
|
|
|
17
17
|
```python
|
|
18
18
|
from portugython import *
|
|
19
19
|
|
|
20
|
-
escreva("
|
|
21
|
-
nome = leia("Qual
|
|
22
|
-
escreva("
|
|
20
|
+
escreva("Olá, Mundo!")
|
|
21
|
+
nome = leia("Qual é seu nome? ")
|
|
22
|
+
escreva("Olá,", nome)
|
|
23
23
|
|
|
24
24
|
numeros = Lista([1, 2, 3, 4, 5])
|
|
25
25
|
numeros.adicione(6)
|
|
@@ -33,9 +33,9 @@ resultado = se(tamanho(pares) > 0, "tem pares", "sem pares")
|
|
|
33
33
|
escreva(resultado)
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
##
|
|
36
|
+
## Módulos da biblioteca padrão
|
|
37
37
|
|
|
38
|
-
Cada
|
|
38
|
+
Cada módulo da stdlib tem uma versão em português que pode ser importada separadamente.
|
|
39
39
|
|
|
40
40
|
### aleatorio (random)
|
|
41
41
|
|
|
@@ -132,7 +132,7 @@ print(p.x, p.y)
|
|
|
132
132
|
```python
|
|
133
133
|
from portugython import iteradores
|
|
134
134
|
|
|
135
|
-
#
|
|
135
|
+
# Combinatória
|
|
136
136
|
for combo in iteradores.combine([1, 2, 3, 4], 2):
|
|
137
137
|
print(combo)
|
|
138
138
|
|
|
@@ -140,7 +140,7 @@ for combo in iteradores.combine([1, 2, 3, 4], 2):
|
|
|
140
140
|
for par in iteradores.produto("AB", "12"):
|
|
141
141
|
print(par)
|
|
142
142
|
|
|
143
|
-
#
|
|
143
|
+
# Acumulação
|
|
144
144
|
totais = list(iteradores.acumule([1, 2, 3, 4, 5]))
|
|
145
145
|
|
|
146
146
|
# Encadeamento
|
|
@@ -152,21 +152,21 @@ unido = list(iteradores.encadeie([1, 2], [3, 4], [5]))
|
|
|
152
152
|
```python
|
|
153
153
|
from portugython import funcional
|
|
154
154
|
|
|
155
|
-
#
|
|
155
|
+
# Redução
|
|
156
156
|
total = funcional.reduzido(lambda a, b: a + b, range(1, 11))
|
|
157
157
|
|
|
158
|
-
#
|
|
158
|
+
# Função parcial
|
|
159
159
|
multiplicar_por_3 = funcional.parcial(lambda a, b: a * b, 3)
|
|
160
160
|
print(multiplicar_por_3(7))
|
|
161
161
|
|
|
162
|
-
#
|
|
162
|
+
# Memoização
|
|
163
163
|
@funcional.cache
|
|
164
164
|
def fibonacci(n):
|
|
165
165
|
if n < 2:
|
|
166
166
|
return n
|
|
167
167
|
return fibonacci(n - 1) + fibonacci(n - 2)
|
|
168
168
|
|
|
169
|
-
#
|
|
169
|
+
# Composição
|
|
170
170
|
dobrar = lambda x: x * 2
|
|
171
171
|
somar_um = lambda x: x + 1
|
|
172
172
|
dobrar_e_somar = funcional.compor(somar_um, dobrar)
|
|
@@ -186,26 +186,26 @@ if m:
|
|
|
186
186
|
# Todos os resultados
|
|
187
187
|
numeros = expressao.encontrar_todos(r"\d+", "1 mais 2 igual 3")
|
|
188
188
|
|
|
189
|
-
#
|
|
189
|
+
# Substituição
|
|
190
190
|
limpo = expressao.substituir(r"\s+", " ", "texto com espacos")
|
|
191
191
|
|
|
192
|
-
#
|
|
192
|
+
# Padrão reutilizável
|
|
193
193
|
email = expressao.Padrao(r"[\w.+-]+@[\w-]+\.[a-z]{2,}")
|
|
194
194
|
if email.encontrar("contato@example.com"):
|
|
195
|
-
print("
|
|
195
|
+
print("E-mail válido")
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
##
|
|
198
|
+
## Referência de builtins
|
|
199
199
|
|
|
200
|
-
### Entrada /
|
|
201
|
-
|
|
|
200
|
+
### Entrada / Saída
|
|
201
|
+
| Português | Python |
|
|
202
202
|
|-----------|--------|
|
|
203
203
|
| `escreva` | `print` |
|
|
204
204
|
| `leia` | `input` |
|
|
205
205
|
| `abra` | `open` |
|
|
206
206
|
|
|
207
207
|
### Tipos
|
|
208
|
-
|
|
|
208
|
+
| Português | Python |
|
|
209
209
|
|-----------|--------|
|
|
210
210
|
| `inteiro` | `int` |
|
|
211
211
|
| `texto` | `str` |
|
|
@@ -218,14 +218,14 @@ if email.encontrar("contato@example.com"):
|
|
|
218
218
|
| `intervalo` | `range` |
|
|
219
219
|
|
|
220
220
|
### Constantes
|
|
221
|
-
|
|
|
221
|
+
| Português | Python |
|
|
222
222
|
|-----------|--------|
|
|
223
223
|
| `Verdadeiro` | `True` |
|
|
224
224
|
| `Falso` | `False` |
|
|
225
225
|
| `Nenhum` | `None` |
|
|
226
226
|
|
|
227
|
-
###
|
|
228
|
-
|
|
|
227
|
+
### Funções de sequência
|
|
228
|
+
| Português | Python |
|
|
229
229
|
|-----------|--------|
|
|
230
230
|
| `tamanho` | `len` |
|
|
231
231
|
| `soma` | `sum` |
|
|
@@ -239,15 +239,15 @@ if email.encontrar("contato@example.com"):
|
|
|
239
239
|
| `mapeado` | `map` |
|
|
240
240
|
| `filtrado` | `filter` |
|
|
241
241
|
|
|
242
|
-
### Operadores
|
|
243
|
-
|
|
|
242
|
+
### Operadores lógicos
|
|
243
|
+
| Português | Python |
|
|
244
244
|
|-----------|--------|
|
|
245
245
|
| `nao(x)` | `not x` |
|
|
246
246
|
| `e(a, b)` | `a and b` |
|
|
247
247
|
| `ou(a, b)` | `a or b` |
|
|
248
248
|
|
|
249
|
-
###
|
|
250
|
-
|
|
|
249
|
+
### Funções utilitárias
|
|
250
|
+
| Português | Python |
|
|
251
251
|
|-----------|--------|
|
|
252
252
|
| `se(c, a, b)` | `a if c else b` |
|
|
253
253
|
| `para_cada(f, it)` | `list(map(f, it))` |
|
|
@@ -257,8 +257,8 @@ if email.encontrar("contato@example.com"):
|
|
|
257
257
|
## Transpilador de palavras-chave
|
|
258
258
|
|
|
259
259
|
Portugython inclui um transpilador completo que traduz a sintaxe do Python
|
|
260
|
-
(palavras-chave) para
|
|
261
|
-
inteiramente em
|
|
260
|
+
(palavras-chave) para português. Isso permite escrever programas Python
|
|
261
|
+
inteiramente em português.
|
|
262
262
|
|
|
263
263
|
### CLI: ptpy
|
|
264
264
|
|
|
@@ -295,7 +295,7 @@ executar_texto("para i em intervalo(3):\n escreva(i)")
|
|
|
295
295
|
executar_arquivo("meu_programa.ptpy")
|
|
296
296
|
```
|
|
297
297
|
|
|
298
|
-
### Programa completo em
|
|
298
|
+
### Programa completo em português (.ptpy)
|
|
299
299
|
|
|
300
300
|
```python
|
|
301
301
|
# fatorial.ptpy
|
|
@@ -331,7 +331,7 @@ finalmente:
|
|
|
331
331
|
|
|
332
332
|
### Tabela de palavras-chave
|
|
333
333
|
|
|
334
|
-
|
|
|
334
|
+
| Português | Python | | Português | Python |
|
|
335
335
|
|-----------|--------|-|-----------|--------|
|
|
336
336
|
| `se` | `if` | | `senao` | `else` |
|
|
337
337
|
| `senaose` | `elif` | | `para` | `for` |
|
|
@@ -352,17 +352,17 @@ finalmente:
|
|
|
352
352
|
| `Verdadeiro` | `True` | | `Falso` | `False` |
|
|
353
353
|
| `Nenhum` | `None` | | | |
|
|
354
354
|
|
|
355
|
-
> **Nota**: Palavras como `e`, `ou`, `de`, `com` e `em`
|
|
356
|
-
> reservadas no contexto de arquivos `.ptpy`. Evite
|
|
357
|
-
>
|
|
358
|
-
>
|
|
355
|
+
> **Nota**: Palavras como `e`, `ou`, `de`, `com` e `em` são palavras-chave
|
|
356
|
+
> reservadas no contexto de arquivos `.ptpy`. Evite usá-las como nomes de
|
|
357
|
+
> variáveis nesses arquivos, assim como não se usa `if` ou `for` como
|
|
358
|
+
> variáveis em Python normal.
|
|
359
359
|
|
|
360
360
|
## Contribuir
|
|
361
361
|
|
|
362
|
-
1. Crie um fork deste
|
|
362
|
+
1. Crie um fork deste repositório
|
|
363
363
|
2. Crie uma branch nova a partir de main
|
|
364
364
|
3. Envie um pull request
|
|
365
365
|
|
|
366
|
-
##
|
|
366
|
+
## Licença
|
|
367
367
|
|
|
368
368
|
MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""portugython - uma
|
|
1
|
+
"""portugython - uma tradução em Português das funções/módulos/pacotes do Python."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -19,9 +19,9 @@ from portugython.transpilador import (
|
|
|
19
19
|
traduzir_para_portugues,
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
__version__ = "0.4.
|
|
22
|
+
__version__ = "0.4.1"
|
|
23
23
|
|
|
24
|
-
# Instala o gancho de
|
|
24
|
+
# Instala o gancho de importação automaticamente
|
|
25
25
|
instalar()
|
|
26
26
|
|
|
27
27
|
# ---------------------------------------------------------------------------
|
|
@@ -118,7 +118,7 @@ Falso = False
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
def nao(valor: object) -> bool:
|
|
121
|
-
"""
|
|
121
|
+
"""Inversão lógica em Português."""
|
|
122
122
|
return not valor
|
|
123
123
|
|
|
124
124
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"""_importador - gancho de
|
|
1
|
+
"""_importador - gancho de importação que permite importar módulos em Português.
|
|
2
2
|
|
|
3
|
-
Quando ativado, permite usar nomes de
|
|
3
|
+
Quando ativado, permite usar nomes de módulos em Português diretamente:
|
|
4
4
|
|
|
5
5
|
import aleatorio
|
|
6
6
|
from matematica import raiz_quadrada
|
|
7
7
|
from colecoes import Contador
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Também permite importar arquivos .ptpy (Python em Português):
|
|
10
10
|
|
|
11
11
|
import meu_modulo # carrega meu_modulo.ptpy se existir
|
|
12
12
|
"""
|
|
@@ -22,7 +22,7 @@ from importlib.machinery import ModuleSpec, SourceFileLoader
|
|
|
22
22
|
from pathlib import Path
|
|
23
23
|
from typing import Sequence
|
|
24
24
|
|
|
25
|
-
# Mapeamento de nome em
|
|
25
|
+
# Mapeamento de nome em Português -> caminho completo do módulo portugython
|
|
26
26
|
MAPA_MODULOS: dict[str, str] = {
|
|
27
27
|
# Matematica e ciencia
|
|
28
28
|
"aleatorio": "portugython.aleatorio",
|
|
@@ -45,7 +45,7 @@ MAPA_MODULOS: dict[str, str] = {
|
|
|
45
45
|
# Texto e expressoes
|
|
46
46
|
"expressao": "portugython.expressao",
|
|
47
47
|
"formatacao": "portugython.formatacao",
|
|
48
|
-
#
|
|
48
|
+
# Serialização e codificação
|
|
49
49
|
"serializacao": "portugython.serializacao",
|
|
50
50
|
"codificacao": "portugython.codificacao",
|
|
51
51
|
"compressao": "portugython.compressao",
|
|
@@ -73,7 +73,7 @@ MAPA_MODULOS: dict[str, str] = {
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
class _CarregadorAlias(importlib.abc.Loader):
|
|
76
|
-
"""Carrega um
|
|
76
|
+
"""Carrega um módulo portugython sob um nome em Português."""
|
|
77
77
|
|
|
78
78
|
def __init__(self, modulo_real: str) -> None:
|
|
79
79
|
self._modulo_real = modulo_real
|
|
@@ -87,7 +87,7 @@ class _CarregadorAlias(importlib.abc.Loader):
|
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
class ImportadorPortugues(importlib.abc.MetaPathFinder):
|
|
90
|
-
"""Intercepta imports de nomes em
|
|
90
|
+
"""Intercepta imports de nomes em Português e redireciona para portugython.*."""
|
|
91
91
|
|
|
92
92
|
def find_spec(
|
|
93
93
|
self,
|
|
@@ -95,7 +95,7 @@ class ImportadorPortugues(importlib.abc.MetaPathFinder):
|
|
|
95
95
|
path: Sequence[str] | None,
|
|
96
96
|
target=None, # noqa: ANN001
|
|
97
97
|
) -> ModuleSpec | None:
|
|
98
|
-
"""Retorna um ModuleSpec para o
|
|
98
|
+
"""Retorna um ModuleSpec para o módulo em Português, se mapeado.
|
|
99
99
|
|
|
100
100
|
Args:
|
|
101
101
|
fullname: Nome completo do modulo sendo importado.
|
|
@@ -115,10 +115,10 @@ _gancho = ImportadorPortugues()
|
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
def listar_modulos() -> dict[str, str]:
|
|
118
|
-
"""Retorna o mapeamento de nomes em
|
|
118
|
+
"""Retorna o mapeamento de nomes em Português para módulos portugython.
|
|
119
119
|
|
|
120
120
|
Returns:
|
|
121
|
-
|
|
121
|
+
Dicionário com nome_portugues -> caminho_modulo.
|
|
122
122
|
"""
|
|
123
123
|
return dict(MAPA_MODULOS)
|
|
124
124
|
|
|
@@ -141,7 +141,7 @@ class _CarregadorPtpy(SourceFileLoader):
|
|
|
141
141
|
|
|
142
142
|
|
|
143
143
|
class ImportadorPtpy(importlib.abc.MetaPathFinder):
|
|
144
|
-
"""Importa arquivos .ptpy (Python em
|
|
144
|
+
"""Importa arquivos .ptpy (Python em Português) de qualquer diretório
|
|
145
145
|
no sys.path."""
|
|
146
146
|
|
|
147
147
|
def find_spec(
|
|
@@ -174,11 +174,11 @@ _gancho_ptpy = ImportadorPtpy()
|
|
|
174
174
|
|
|
175
175
|
|
|
176
176
|
def instalar() -> None:
|
|
177
|
-
"""Instala o importador de
|
|
177
|
+
"""Instala o importador de módulos em Português no sys.meta_path.
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
-
|
|
181
|
-
- Arquivos .ptpy
|
|
179
|
+
Após chamar esta função:
|
|
180
|
+
- Módulos portugython são importáveis pelo nome em Português
|
|
181
|
+
- Arquivos .ptpy são importáveis via import normal
|
|
182
182
|
|
|
183
183
|
Example:
|
|
184
184
|
import aleatorio
|
|
@@ -193,7 +193,7 @@ def instalar() -> None:
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
def desinstalar() -> None:
|
|
196
|
-
"""Remove o importador de
|
|
196
|
+
"""Remove o importador de módulos em Português do sys.meta_path."""
|
|
197
197
|
sys.meta_path[:] = [
|
|
198
198
|
f for f in sys.meta_path
|
|
199
199
|
if not isinstance(f, (ImportadorPortugues, ImportadorPtpy))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"""transpilador - converte
|
|
1
|
+
"""transpilador - converte código Python escrito em Português para Python padrão.
|
|
2
2
|
|
|
3
|
-
Uso como
|
|
3
|
+
Uso como módulo:
|
|
4
4
|
|
|
5
5
|
from portugython.transpilador import traduzir, executar_texto, executar_arquivo
|
|
6
6
|
codigo_py = traduzir("se x > 0:\\n escreva(x)")
|
|
@@ -20,7 +20,7 @@ import tokenize
|
|
|
20
20
|
from pathlib import Path
|
|
21
21
|
|
|
22
22
|
# ---------------------------------------------------------------------------
|
|
23
|
-
# Mapa de palavras-chave:
|
|
23
|
+
# Mapa de palavras-chave: Português -> Python
|
|
24
24
|
# ---------------------------------------------------------------------------
|
|
25
25
|
|
|
26
26
|
MAPA_PALAVRAS_CHAVE: dict[str, str] = {
|
|
@@ -50,7 +50,7 @@ MAPA_PALAVRAS_CHAVE: dict[str, str] = {
|
|
|
50
50
|
"levante": "raise",
|
|
51
51
|
# Gerenciadores de contexto
|
|
52
52
|
"com": "with",
|
|
53
|
-
# Operadores
|
|
53
|
+
# Operadores lógicos (como funções: e/ou/nao já existem em __init__.py,
|
|
54
54
|
# mas aqui traduzimos os tokens da sintaxe)
|
|
55
55
|
"nao": "not",
|
|
56
56
|
"e": "and",
|
|
@@ -73,7 +73,7 @@ MAPA_PALAVRAS_CHAVE: dict[str, str] = {
|
|
|
73
73
|
"Nenhum": "None",
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
# Mapa inverso (Python ->
|
|
76
|
+
# Mapa inverso (Python -> Português) para referência
|
|
77
77
|
MAPA_INVERSO: dict[str, str] = {v: k for k, v in MAPA_PALAVRAS_CHAVE.items()}
|
|
78
78
|
|
|
79
79
|
# Palavras reservadas em portugues (nao podem ser nomes de variaveis)
|
|
@@ -85,17 +85,17 @@ PALAVRAS_RESERVADAS: frozenset[str] = frozenset(MAPA_PALAVRAS_CHAVE.keys())
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def traduzir(codigo: str) -> str:
|
|
88
|
-
"""Traduz
|
|
88
|
+
"""Traduz código Python em Português para Python padrão.
|
|
89
89
|
|
|
90
90
|
Usa o tokenizador do Python para substituir apenas tokens NAME que
|
|
91
|
-
correspondem a palavras-chave em
|
|
92
|
-
identificadores compostos (ex: minha_se_variavel)
|
|
91
|
+
correspondem a palavras-chave em Português. Strings, comentários e
|
|
92
|
+
identificadores compostos (ex: minha_se_variavel) são intocados.
|
|
93
93
|
|
|
94
94
|
Args:
|
|
95
|
-
codigo:
|
|
95
|
+
codigo: Código fonte em Português.
|
|
96
96
|
|
|
97
97
|
Returns:
|
|
98
|
-
|
|
98
|
+
Código fonte Python válido.
|
|
99
99
|
|
|
100
100
|
Example:
|
|
101
101
|
>>> traduzir("se x > 0:\\n retorne x")
|
|
@@ -119,15 +119,15 @@ def traduzir(codigo: str) -> str:
|
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
def traduzir_para_portugues(codigo: str) -> str:
|
|
122
|
-
"""Traduz
|
|
122
|
+
"""Traduz código Python padrão para Python em Português.
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Operação inversa de traduzir().
|
|
125
125
|
|
|
126
126
|
Args:
|
|
127
|
-
codigo:
|
|
127
|
+
codigo: Código fonte Python padrão.
|
|
128
128
|
|
|
129
129
|
Returns:
|
|
130
|
-
|
|
130
|
+
Código fonte em Português.
|
|
131
131
|
"""
|
|
132
132
|
tokens_novos: list[tuple] = []
|
|
133
133
|
try:
|
|
@@ -154,13 +154,13 @@ def executar_texto(
|
|
|
154
154
|
globais: dict | None = None,
|
|
155
155
|
locais: dict | None = None,
|
|
156
156
|
) -> None:
|
|
157
|
-
"""Traduz e executa uma string de
|
|
157
|
+
"""Traduz e executa uma string de código em Português.
|
|
158
158
|
|
|
159
|
-
O ambiente de
|
|
159
|
+
O ambiente de execução inclui automaticamente todos os nomes definidos
|
|
160
160
|
em portugython (escreva, intervalo, Verdadeiro, etc.).
|
|
161
161
|
|
|
162
162
|
Args:
|
|
163
|
-
codigo:
|
|
163
|
+
codigo: Código em Português a executar.
|
|
164
164
|
globais: Namespace global adicional. Mesclado com portugython.
|
|
165
165
|
locais: Namespace local. None usa o global.
|
|
166
166
|
|
|
@@ -182,9 +182,9 @@ def executar_texto(
|
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
def executar_arquivo(caminho: str | Path) -> None:
|
|
185
|
-
"""Traduz e executa um arquivo .ptpy ou .py em
|
|
185
|
+
"""Traduz e executa um arquivo .ptpy ou .py em Português.
|
|
186
186
|
|
|
187
|
-
O ambiente de
|
|
187
|
+
O ambiente de execução inclui automaticamente todos os nomes definidos
|
|
188
188
|
em portugython.
|
|
189
189
|
|
|
190
190
|
Args:
|
|
@@ -210,12 +210,12 @@ def executar_arquivo(caminho: str | Path) -> None:
|
|
|
210
210
|
|
|
211
211
|
|
|
212
212
|
def mostrar_traducao(codigo: str) -> None:
|
|
213
|
-
"""Imprime o
|
|
213
|
+
"""Imprime o código traduzido para Python padrão.
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
Útil para depuração e aprendizado.
|
|
216
216
|
|
|
217
217
|
Args:
|
|
218
|
-
codigo:
|
|
218
|
+
codigo: Código em Português.
|
|
219
219
|
"""
|
|
220
220
|
print(traduzir(codigo))
|
|
221
221
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|