From 44b845e91c15d4a63a6348423658fba5945f1ea5 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Tue, 25 Jun 2019 06:31:25 +0200 Subject: [PATCH 01/28] Set theme jekyll-theme-slate --- _config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 _config.yml diff --git a/_config.yml b/_config.yml new file mode 100644 index 00000000..c7418817 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-slate \ No newline at end of file From 95abf2a0d68b4014dfb159a8f7626a1a3257c156 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Tue, 25 Jun 2019 06:34:26 +0200 Subject: [PATCH 02/28] Set theme jekyll-theme-minimal --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index c7418817..2f7efbea 100644 --- a/_config.yml +++ b/_config.yml @@ -1 +1 @@ -theme: jekyll-theme-slate \ No newline at end of file +theme: jekyll-theme-minimal \ No newline at end of file From 1bfecc3ad7592d9688210f8233604b302e05a6a1 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Tue, 5 May 2020 18:00:23 +0200 Subject: [PATCH 03/28] Add a link to interactive machine learning experiments. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f36eb28e..b87e41da 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ syntax of [standard Python statements and constructions](#table-of-contents). Al code is full of assertions you'll be able to see expected functions/statements output right away without launching them. +> _You might also be interested in 🤖 [Interactive Machine Learning Experiments](https://github.com/trekhleb/machine-learning-experiments)_ + ## How to Use This Repository Each Python script in this repository has the following structure: From 5be75505d60cbd2f26ddb42b205dcc95297be054 Mon Sep 17 00:00:00 2001 From: "Vilmacio M. Silva" Date: Fri, 29 May 2020 16:02:28 -0300 Subject: [PATCH 04/28] [PT-BR] Portuguese Translation v1.0 (#14) * main README.md updated * Adds README.pt-BR.md Co-authored-by: vilmacio22 --- README.md | 2 + README.pt-BR.md | 211 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 213 insertions(+) create mode 100644 README.pt-BR.md diff --git a/README.md b/README.md index b87e41da..92ef11cc 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ > This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain code examples with explanations, different use cases and links to further readings. +_Read this in_ [_Português_](README.pt-BR.md) + It is a **playground** because you may change or add the code to see how it works and [test it out](#testing-the-code) using assertions. It also allows you to [lint the code](#linting-the-code) you've wrote and check if it fits to Python code style guide. diff --git a/README.pt-BR.md b/README.pt-BR.md new file mode 100644 index 00000000..f37bc1ba --- /dev/null +++ b/README.pt-BR.md @@ -0,0 +1,211 @@ +# Playground e Cheatsheet Para Aprender Python + +[![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) + +> Essa é uma coleção de scripts Python dividida em [tópicos](#índice) que contém +exemplos de código com explicações, diferentes usos e links para outras leituras. + +_Ler em_ [_English_](README.md) + +É um **playground** porque você pode fazer alterações no código para ver como ele se comporta, +além de [testá-lo](#testando-o-código) usando asserções. Também é possível +[revisar o código](#revisando-o-código) que você escreveu automaticamente e verificar se ele se encaixa +no guia de estilo de código Python. +Isso tudo pode tornar seu processo de aprendizagem mais interativo e ajudar a manter a qualidade +do código bastante alta desde o início. + +É um **cheatsheet** porque você pode voltar a esses exemplos de código quando quiser recapitular a sintaxe das +[estruturas padrão do Python](#índice). O código está cheio de asserções, então você poderá ver o retorno das funções sem precisar executá-las. + +> _Você pode se interessar também por 🤖 [Interactive Machine Learning Experiments](https://github.com/trekhleb/machine-learning-experiments)_ + +## Como Usar Esse Repositório + +Nesse repositório, cada script Python possui a seguinte estrutura: + +```python +"""Lists <--- Nome do tópico + +# @see: https://www.learnpython.org/en/Lists <-- Link para outras leituras. + +A seguir, uma explicação mais detalhada do tópico atual (ex, informações gerais sobre listas (Lists)). +""" + + +def test_list_type(): + """Explicação do subtópico. + + Cada arquivo contém funções de teste que ilustram subtópicos (ou seja, tipo de lista, métodos de lista). + """ + + # Here is an example of how to build a list. <-- Comentários em inglês explicam a ação. + squares = [1, 4, 9, 16, 25] + + # Lists can be indexed and sliced. + # Indexing returns the item. + assert squares[0] == 1 # <-- As asserções ilustram o resultado. + # Slicing returns a new list. + assert squares[-3:] == [9, 16, 25] # <-- As asserções ilustram o resultado. +``` + +Então você pode querer fazer o seguinte: + +- [Encontrar o tópico](#índice) que deseja aprender ou recapitular. +- Ler os comentários e/ou a documentação vinculada em cada script (como no exemplo acima). +- Analisar os exemplos e asserções para ver exemplos de uso e saída esperada das funções. +- Alterar o código ou adicionar novas asserções para ver o que acontece. +- [Executar testes](#testando-o-código) e [revisar o código](#revisando-o-código) para ver se ele +funciona e para saber se está escrito corretamente. + +## Índice + +1. **Começando** + - [O que é Python](src/getting_started/what_is_python.md) + - [Sintaxe Python](src/getting_started/python_syntax.md) + - [Variáveis](src/getting_started/test_variables.py) +2. **Operators** + - [Operadores Aritméticos](src/operators/test_arithmetic.py) (`+`, `-`, `*`, `/`, `//`, `%`, `**`) + - [Operadores Bitwise](src/operators/test_bitwise.py) (`&`, `|`, `^`, `>>`, `<<`, `~`) + - [Operadores de Atribuição](src/operators/test_assigment.py) (`=`, `+=`, `-=`, `/=`, `//=` etc.) + - [Operadores de Comparação](src/operators/test_comparison.py) (`==`, `!=`, `>`, `<`, `>=`, `<=`) + - [Operadores Lógicos](src/operators/test_logical.py) (`and`, `or`, `not`) + - [Operadores de Indentidade](src/operators/test_identity.py) (`is`, `is not`) + - [Operadores de Associação](src/operators/test_membership.py) (`in`, `not in`) +3. **Tipos de Dados** + - [Números](src/data_types/test_numbers.py) (incluindo boleanos) + - [Strings](src/data_types/test_strings.py) e seus métodos + - [Listas](src/data_types/test_lists.py) e seus métodos (incluindo lista de compreensões) + - [Tuplas](src/data_types/test_tuples.py) + - [Conjuntos](src/data_types/test_sets.py) e seus métodos + - [Dicionários](src/data_types/test_dictionaries.py) + - [Casting de Tipo](src/data_types/test_type_casting.py) +4. **Controles de Fluxo** + - [A declaração `if`](src/control_flow/test_if.py) + - [A declaração `for`](src/control_flow/test_for.py) (e a função `range()`) + - [A declaração `while`](src/control_flow/test_while.py) + - [A declaração `try`](src/control_flow/test_try.py) + - [A declaração `break`](src/control_flow/test_break.py) + - [A declaração `continue`](src/control_flow/test_continue.py) +5. **Funções** + - [Definição de Função](src/functions/test_function_definition.py) (declaração `def` e `return`) + - [Variáveis Dentro das Funções](src/functions/test_function_scopes.py) (declaração `global` e `nonlocal`) + - [Valores Padrão de Argumentos](src/functions/test_function_default_arguments.py) + - [Argumentos de palavras-chave](src/functions/test_function_keyword_arguments.py) + - [Listas de Argumento Arbitrárias](src/functions/test_function_arbitrary_arguments.py) + - [Desfazendo Lista de Argumentos](src/functions/test_function_unpacking_arguments.py) (declaração `*` e `**`) + - [Expressões Lambda](src/functions/test_lambda_expressions.py) (declaração `lambda`) + - [Documentação das Strings](src/functions/test_function_documentation_string.py) + - [Função de Anotações](src/functions/test_function_annotations.py) + - [Função de Decoradores](src/functions/test_function_decorators.py) +6. **Classes** + - [Definição de Classe](src/classes/test_class_definition.py) (declaração `class`) + - [Classes dos Objetos](src/classes/test_class_objects.py) + - [Instância dos Objetos](src/classes/test_instance_objects.py) + - [Métodos de Objetos](src/classes/test_method_objects.py) + - [Variável de Classe e Instância](src/classes/test_class_and_instance_variables.py) + - [Herança](src/classes/test_inheritance.py) + - [Herança Múltipla](src/classes/test_multiple_inheritance.py) +7. **Módulos** + - [Módulos](src/modules/test_modules.py) (declaração `import`) + - [Pacotes](src/modules/test_packages.py) +8. **Erros e Exceções** + - [Tratando Exceções](src/exceptions/test_handle_exceptions.py) (declaração `try`) + - [Levantando Exceções](src/exceptions/test_raise_exceptions.py) (declaração `raise`) +9. **Arquivos** + - [Lendo e Escrevendo](src/files/test_file_reading.py) (declaração `with`) + - [Métodos de Objetos de Arquivos](src/files/test_file_methods.py) +10. **Adicional** + - [A declaração `pass`](src/additions/test_pass.py) + - [Geradores](src/additions/test_generators.py) (declaração `yield`) +11. **Algumas Bibliotecas Padrão** + - [Serialization](src/standard_libraries/test_json.py) (biblioteca `json`) + - [File Wildcards](src/standard_libraries/test_glob.py) (biblioteca `glob`) + - [String Pattern Matching](src/standard_libraries/test_re.py) (biblioteca `re`) + - [Mathematics](src/standard_libraries/test_math.py) (bibliotecas `math`, `random` e `statistics`) + - [Tempo e Datas](src/standard_libraries/test_datetime.py) (biblioteca `datetime`) + - [Compressão de dados](src/standard_libraries/test_zlib.py) (biblioteca `zlib`) + +## Pré-requisitos + +**Instalando o Python** + +Certifique-se de ter o [Python3 instalado](https://realpython.com/installing-python/) em sua máquina. + +Você pode usar a biblioteca padrão do Python [venv](https://docs.python.org/3/library/venv.html) +para criar ambientes virtuais e ter o Python, pip e todos os outros pacotes a serem instalados + a partir do diretório local do projeto para evitar mexer com pacotes externos ou do sistema. + +Dependendo da sua instalação, você pode ter acesso ao interpretador Python3 executando `python` ou `python3`. O mesmo vale para o gerenciador de pacotes pip, você pode acessá-lo executando `pip` ou `pip3`. + +Você pode ver a versão do seu Python executando: + +```bash +python --version +``` + +Observe que neste repositório sempre que você vê o `python`, será assumido que é o Python **3**. + +**Instalando dependências** + +Instale todas as dependências necessárias para o projeto executando: + +```bash +pip install -r requirements.txt +``` + +## Testando o Código + +Testes são feitos usando o framework [pytest](https://docs.pytest.org/en/latest/). + +Você pode adicionar novos testes criando arquivos e funções com o prefixo `test_` +(ex. `test_topic.py` com a função `def test_sub_topic()` dentro). + +Para executar todos os testes, execute o seguinte comando na pasta raiz do projeto: + +```bash +pytest +``` + +Para executar testes específicos, execute: + +```bash +pytest ./path/to/the/test_file.py +``` + +## Revisando o Código + +A revisão é feita usando as bibliotecas [pylint](http://pylint.pycqa.org/) e [flake8](http://flake8.pycqa.org/en/latest/). + +### PyLint + +Para verificar se o código está escrito de acordo com o guia de estilo +do [PEP 8](https://www.python.org/dev/peps/pep-0008/), execute: + +```bash +pylint ./src/ +``` + +Caso o pylint detecte um erro (ex. `missing-docstring`), convém ler mais sobre erros específicos executando: + +```bash +pylint --help-msg=missing-docstring +``` + +[Saber mais sobre PyLint](http://pylint.pycqa.org/) + +### Flake8 + +Para verificar se o código está escrito de acordo com o guia de estilo +do [PEP 8](https://www.python.org/dev/peps/pep-0008/), execute: + +```bash +flake8 ./src +``` + +Ou, se você quiser uma saída mais detalhada, execute: + +```bash +flake8 ./src --statistics --show-source --count +``` + +[Saber mais sobre Flake8](http://flake8.pycqa.org/en/latest/) From e6c8cfd4df09b7290a0fa5dc710bb0bd90522233 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 29 May 2020 21:04:50 +0200 Subject: [PATCH 05/28] Minor fixes. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 92ef11cc..faf34882 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain code examples with explanations, different use cases and links to further readings. -_Read this in_ [_Português_](README.pt-BR.md) +_Read this in_ [_Português_](README.pt-BR.md). It is a **playground** because you may change or add the code to see how it works and [test it out](#testing-the-code) using assertions. It also allows you From 427de77d0cacb75eab99757c373fa2a3feb173fc Mon Sep 17 00:00:00 2001 From: "Vilmacio M. Silva" Date: Sat, 30 May 2020 05:51:54 -0300 Subject: [PATCH 06/28] [PT-BR] Portuguese Translation v2.0 (#16) * main README.md updated * Adds README.pt-BR.md * [FIX] pt-BR Translate Co-authored-by: vilmacio22 --- README.pt-BR.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.pt-BR.md b/README.pt-BR.md index f37bc1ba..e6bd025f 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -5,7 +5,7 @@ > Essa é uma coleção de scripts Python dividida em [tópicos](#índice) que contém exemplos de código com explicações, diferentes usos e links para outras leituras. -_Ler em_ [_English_](README.md) +_Ler em_ [_English_](README.md). É um **playground** porque você pode fazer alterações no código para ver como ele se comporta, além de [testá-lo](#testando-o-código) usando asserções. Também é possível @@ -63,7 +63,7 @@ funciona e para saber se está escrito corretamente. - [O que é Python](src/getting_started/what_is_python.md) - [Sintaxe Python](src/getting_started/python_syntax.md) - [Variáveis](src/getting_started/test_variables.py) -2. **Operators** +2. **Operadores** - [Operadores Aritméticos](src/operators/test_arithmetic.py) (`+`, `-`, `*`, `/`, `//`, `%`, `**`) - [Operadores Bitwise](src/operators/test_bitwise.py) (`&`, `|`, `^`, `>>`, `<<`, `~`) - [Operadores de Atribuição](src/operators/test_assigment.py) (`=`, `+=`, `-=`, `/=`, `//=` etc.) @@ -121,9 +121,9 @@ funciona e para saber se está escrito corretamente. - [Serialization](src/standard_libraries/test_json.py) (biblioteca `json`) - [File Wildcards](src/standard_libraries/test_glob.py) (biblioteca `glob`) - [String Pattern Matching](src/standard_libraries/test_re.py) (biblioteca `re`) - - [Mathematics](src/standard_libraries/test_math.py) (bibliotecas `math`, `random` e `statistics`) + - [Matemática](src/standard_libraries/test_math.py) (bibliotecas `math`, `random` e `statistics`) - [Tempo e Datas](src/standard_libraries/test_datetime.py) (biblioteca `datetime`) - - [Compressão de dados](src/standard_libraries/test_zlib.py) (biblioteca `zlib`) + - [Comprimindo Dados](src/standard_libraries/test_zlib.py) (biblioteca `zlib`) ## Pré-requisitos @@ -209,3 +209,7 @@ flake8 ./src --statistics --show-source --count ``` [Saber mais sobre Flake8](http://flake8.pycqa.org/en/latest/) + +--- + +Traduzido por [vilmacio22](https://github.com/vilmacio22). \ No newline at end of file From 3c0a5c184858868f3c04e2650a98d7401ad825b0 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Mon, 6 Jul 2020 22:41:30 +0200 Subject: [PATCH 07/28] Create FUNDING.yml --- .github/FUNDING.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..25b1a776 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: trekhleb # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 5b9ea5a827288f2dd5daaea25cb71ba7cb621872 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Wed, 8 Jul 2020 07:55:22 +0200 Subject: [PATCH 08/28] Update FUNDING.yml --- .github/FUNDING.yml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 25b1a776..deda41e7 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,12 +1,3 @@ -# These are supported funding model platforms - -github: trekhleb # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +# @see: https://docs.github.com/en/github/administering-a-repository/displaying-a-sponsor-button-in-your-repository +github: trekhleb +patreon: trekhleb From cf58262afcaa1e6f006b9ad1b6ad9db28d34e6d7 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Wed, 8 Jul 2020 18:09:05 +0200 Subject: [PATCH 09/28] Minor fixes. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index faf34882..2a39aa0b 100644 --- a/README.md +++ b/README.md @@ -214,3 +214,7 @@ flake8 ./src --statistics --show-source --count ``` [More about Flake8](http://flake8.pycqa.org/en/latest/) + +## Supporting the project + +You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). From 25e6b2a548b8c581bb8c5b7162b9b4e984a48c8b Mon Sep 17 00:00:00 2001 From: Sven Eschlbeck <66701689+sveneschlbeck@users.noreply.github.com> Date: Thu, 28 Oct 2021 16:54:49 +0200 Subject: [PATCH 10/28] Adding a test function for user input (#40) * Adding a test function for user input in terminal * Update README.md * Update README.md * Update README.md --- README.md | 2 ++ src/user_input/test_input.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/user_input/test_input.py diff --git a/README.md b/README.md index 2a39aa0b..818cf4e2 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,8 @@ written correctly. - [Mathematics](src/standard_libraries/test_math.py) (`math`, `random`, `statistics` libraries) - [Dates and Times](src/standard_libraries/test_datetime.py) (`datetime` library) - [Data Compression](src/standard_libraries/test_zlib.py) (`zlib` library) +12. **User input** + - [Terminal input](src/user_input/test_input.py) from users to interact with the program ## Prerequisites diff --git a/src/user_input/test_input.py b/src/user_input/test_input.py new file mode 100644 index 00000000..a567d96f --- /dev/null +++ b/src/user_input/test_input.py @@ -0,0 +1,17 @@ +"""User input + +# @see https://docs.python.org/3/library/functions.html#input + +User input prompts are very helpful when it comes to interactive programming. Not only in games but also in standard file operations, you may want your user to interact with the program. +Therefore, the user needs the opportunity to be able to put in information. +""" + + +def user_input(): + """Input prompt""" + + """Printing statement to signal the user that we are waiting for input""" + user_input = input("Please type in your name.\n") + + """Printing a message based on the input""" + print(f"Welcome, {user_input}!") From 19353f72aacd68ad38dab3f837c3cb507f24f7e3 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Thu, 28 Oct 2021 17:37:16 +0200 Subject: [PATCH 11/28] Add Input. --- README.md | 4 ++-- src/user_input/test_input.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 818cf4e2..e1fb02cd 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ written correctly. - [Packages](src/modules/test_packages.py) 8. **Errors and Exceptions** - [Handling Exceptions](src/exceptions/test_handle_exceptions.py) (`try` statement) - - [Raising Exceptions](src/exceptions/test_raise_exceptions.py) (`raise` statement) + - [Raising Exceptions](src/exceptions/test_raise_exceptions.py) (`raise` statement) 9. **Files** - [Reading and Writing](src/files/test_file_reading.py) (`with` statement) - [Methods of File Objects](src/files/test_file_methods.py) @@ -126,7 +126,7 @@ written correctly. - [Dates and Times](src/standard_libraries/test_datetime.py) (`datetime` library) - [Data Compression](src/standard_libraries/test_zlib.py) (`zlib` library) 12. **User input** - - [Terminal input](src/user_input/test_input.py) from users to interact with the program + - [Terminal input](src/user_input/test_input.py) (`input` statement) ## Prerequisites diff --git a/src/user_input/test_input.py b/src/user_input/test_input.py index a567d96f..0acbbf76 100644 --- a/src/user_input/test_input.py +++ b/src/user_input/test_input.py @@ -1,6 +1,6 @@ """User input -# @see https://docs.python.org/3/library/functions.html#input +@see https://docs.python.org/3/library/functions.html#input User input prompts are very helpful when it comes to interactive programming. Not only in games but also in standard file operations, you may want your user to interact with the program. Therefore, the user needs the opportunity to be able to put in information. @@ -10,8 +10,8 @@ def user_input(): """Input prompt""" - """Printing statement to signal the user that we are waiting for input""" - user_input = input("Please type in your name.\n") + # Printing statement to signal the user that we are waiting for input. + user_input = input("Please type in your name\n") - """Printing a message based on the input""" + # Printing a message based on the input. print(f"Welcome, {user_input}!") From 6a84155fcf0b7d090cf2e2553a0e78b1d8746900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20De=20Freitas?= <37962411+JoseDeFreitas@users.noreply.github.com> Date: Thu, 28 Oct 2021 12:05:01 -0400 Subject: [PATCH 12/28] Add Spanish translation (#31) * Translate text into Spanish * Add Spanish translation reference * Add Spanish translation reference * Fix links Co-authored-by: Oleksii Trekhleb --- README.es.md | 219 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- README.pt-BR.md | 4 +- 3 files changed, 222 insertions(+), 3 deletions(-) create mode 100644 README.es.md diff --git a/README.es.md b/README.es.md new file mode 100644 index 00000000..60a38138 --- /dev/null +++ b/README.es.md @@ -0,0 +1,219 @@ +# Playground y Cheatsheet para aprender Python + +[![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) + +> Esta es una colección de scripts de Python divididos en [categorías](#contenido) que contienen +ejemplos de código con sus explicaciones, diferentes usos y links a recursos adicionales. + +_Lee esto en_ [_Inglés_](README.md), [_Portugués_](README.pt-BR.md). + +Es un **playground** ya que puedes cambiar o añadir cosas al código para ver +cómo funciona y [probarlo](#probando-el-código) usando aserciones. También puedes +[revisar el código](#revisando-el-código) que has escrito y averiguar si está acorde con +la guía de estilos de Python. Todo esto, en conjunto, puede hacer que tu proceso de aprendizaje +sea más interactivo y puede ayudarte a mantener la calidad del código muy alta desde el principio. + +Es un **cheatsheet** porque puedes regresar y revisar los ejemplos de código para +fortalecer tus conocimientos sobre las [sentencias y contrucciones estándar de Python](#contenido). +Además, ya que el código tiene muchas aserciones, podrás ver el resultado de las funciones/sentencias en el mismo +código sin la necesidad de ejecutarlos. + +> _También puede interesarte 🤖 [Interactive Machine Learning Experiments](https://github.com/trekhleb/machine-learning-experiments)_ + +## Cómo usar este repositorio + +Cada script de Python en este repositorio sigue la estructura: + +```python +"""Lists <--- Nombre del tema + +# @see: https://www.learnpython.org/en/Lists <-- Link a recurso adicional + +Aquí puede haber una explicación detallada del tema en concreto (ej: información general sobre listas). +""" + + +def test_list_type(): + """Explicación del sub-tema. + + Cada archivo contiene funciones de prueba que muestran sub-temas (ej: tipos de listas, métodos en listas). + """ + + # Este es un ejemplo de cómo construir una lista. <-- Estos comentarios explican el procedimiento + squares = [1, 4, 9, 16, 25] + + # Las listas pueden ser indexadas y cortadas. + # Al indexar devuelve el item. + assert squares[0] == 1 # <-- Estas aserciones muestran el resultado. + # Al cortar devuelve una nueva lista. + assert squares[-3:] == [9, 16, 25] # <-- Estas aserciones muestran el resultado. +``` + +Normalmente, querrás hacer lo siguiente: + +- [Encontrar el tema](#contenido) que quieres aprender o revisar. +- Leer los comentarios y/o la documentación que está escrita en cada docstring del script (toma como ejemplo el script de arriba). +- Ver los ejemplos de código y las aserciones para conocer diferentes maneras de usar el código y entender el resultado previsto. +- Cambiar el código o añadir nuevas aserciones para ver cómo funcionan las cosas. +- [Probar](#probando-el-código) y [revisar](#revisando-el-código) el código para ver si funciona y si está escrito +correctamente. + +## Contenido + +1. **Empezando** + - [¿Qué es Python?](src/getting_started/what_is_python.md) + - [Sintaxis de Python](src/getting_started/python_syntax.md) + - [Variables](src/getting_started/test_variables.py) +2. **Operadores** + - [Operadores aritméticos](src/operators/test_arithmetic.py) (`+`, `-`, `*`, `/`, `//`, `%`, `**`) + - [Operadores Bitwise](src/operators/test_bitwise.py) (`&`, `|`, `^`, `>>`, `<<`, `~`) + - [Operadores de atribución](src/operators/test_assigment.py) (`=`, `+=`, `-=`, `/=`, `//=` etc.) + - [Operadores de comparación](src/operators/test_comparison.py) (`==`, `!=`, `>`, `<`, `>=`, `<=`) + - [Operadores lógicos](src/operators/test_logical.py) (`and`, `or`, `not`) + - [Operadores de identidad](src/operators/test_identity.py) (`is`, `is not`) + - [Operadores de asociación](src/operators/test_membership.py) (`in`, `not in`) +3. **Tipos de datos** + - [Números](src/data_types/test_numbers.py) (incluyendo booleans) + - [Strings](src/data_types/test_strings.py) y sus métodos + - [Listas](src/data_types/test_lists.py) y sus métodos (incluyendo comprensión de listas) + - [Tuples](src/data_types/test_tuples.py) + - [Sets](src/data_types/test_sets.py) y sus métodos + - [Diccionarios](src/data_types/test_dictionaries.py) + - [Tipo de casting](src/data_types/test_type_casting.py) +4. **Control de flujo** + - [La sentencia `if`](src/control_flow/test_if.py) + - [La sentencia `for`](src/control_flow/test_for.py) (y la función `range()`) + - [La sentencia `while`](src/control_flow/test_while.py) + - [La sentencia `try`](src/control_flow/test_try.py) + - [La sentencia `break`](src/control_flow/test_break.py) + - [La sentencia `continue`](src/control_flow/test_continue.py) +5. **Funciones** + - [Definición de función](src/functions/test_function_definition.py) (sentencias `def` y `return`) + - [Ámbito de variables dentro de funciones](src/functions/test_function_scopes.py) (sentencias `global` y `nonlocal`) + - [Valores de argumento predeterminados](src/functions/test_function_default_arguments.py) + - [Argumentos de palabras clave](src/functions/test_function_keyword_arguments.py) + - [Listas de argumento arbitrario](src/functions/test_function_arbitrary_arguments.py) + - [Listas de argumentos en funciones](src/functions/test_function_unpacking_arguments.py) (sentencias `*` y `**`) + - [Expresiones Lambda](src/functions/test_lambda_expressions.py) (sentencia `lambda`) + - [Strings de documentación](src/functions/test_function_documentation_string.py) + - [Anotaciones en funciones](src/functions/test_function_annotations.py) + - [Decoradores de funciones](src/functions/test_function_decorators.py) +6. **Clases** + - [Definición de clase](src/classes/test_class_definition.py) (sentencia `class`) + - [Objetos de clase](src/classes/test_class_objects.py) + - [Objetos de instancia](src/classes/test_instance_objects.py) + - [Métodos de objetos](src/classes/test_method_objects.py) + - [Variables de clase y de instancia](src/classes/test_class_and_instance_variables.py) + - [Herencia](src/classes/test_inheritance.py) + - [Herencia múltiple](src/classes/test_multiple_inheritance.py) +7. **Módulos** + - [Módulos](src/modules/test_modules.py) (sentencia `import`) + - [Paquetes](src/modules/test_packages.py) +8. **Errores y excepciones** + - [Controlando excepciones](src/exceptions/test_handle_exceptions.py) (sentencia `try`) + - [Generando excepciones](src/exceptions/test_raise_exceptions.py) (sentencia `raise`) +9. **Archivos** + - [Leyendo y escribiendo](src/files/test_file_reading.py) (sentencia `with`) + - [Métodos de objetos de archivo](src/files/test_file_methods.py) +10. **Adicionales** + - [La sentencia `pass`](src/additions/test_pass.py) + - [Generadores](src/additions/test_generators.py) (sentencia `yield`) +11. **Pequeño tour de las librerías estándar** + - [Serialización](src/standard_libraries/test_json.py) (librería `json`) + - [Parámetros en archivos](src/standard_libraries/test_glob.py) (librería `glob`) + - [Expresiones regulares](src/standard_libraries/test_re.py) (librearía `re`) + - [Matemática](src/standard_libraries/test_math.py) (librerías `math`, `random` y `statistics`) + - [Fechas y horas](src/standard_libraries/test_datetime.py) (librería `datetime`) + - [Compresión de datos](src/standard_libraries/test_zlib.py) (librearía `zlib`) + +## Pre-requisitos + +**Instalando Python** + +Asegúrate de que tienes [Python3 instalado](https://realpython.com/installing-python/) en tu sistema. + +Podrías utilizar la librería estándar [venv](https://docs.python.org/es/3/library/venv.html) para crear +entornos virtuales y tener Python, pip y todos los paquetes instalados en el directorio de tu +proyecto local para evitar cometer errores con paquetes del sistema y sus versiones. + +Dependiendo de la instalación, tendrás acceso a Python3 ejecutando `python` o `python3`. Lo mismo +aplica para el administrador de paquetes pip - puedes tener acceso a él ejecutando `pip` o `pip3`. + +Puedes ver tu versión actual de Python ejecutando: + +```bash +python --version +``` + +Ten en cuenta que cuando leas `python` en este repositorio, se asume que es Python **3**. + +**Instalando dependencias** + +Instala todas las depencias requeridas para el proyecto ejecutando: + +```bash +pip install -r requirements.txt +``` + +## Probando el código + +Las pruebas son hechas usando el framework [pytest](https://docs.pytest.org/en/latest/). + +Puedes añadir más pruebas por ti mismo añadiendo archivos y funciones con el prefijo `test_` +(ej: `test_topic.py` con la función `def test_sub_topic()` adentro). + +Para ejecutar todas las pruebas, por favor escribe el siguiente comando desde el directorio +raíz del proyecto: + +```bash +pytest +``` + +Para ejecutar diferentes pruebas escribe: + +```bash +pytest ./path/to/the/test_file.py +``` + +## Revisando el código + +La revisión del código está hecha usando las librerías [pylint](http://pylint.pycqa.org/) y [flake8](http://flake8.pycqa.org/en/latest/). + +### PyLint + +Para revisar si el código sigue la guía de estilos +[PEP 8](https://www.python.org/dev/peps/pep-0008/), por favor ejecuta: + +```bash +pylint ./src/ +``` + +En caso de que linter detecte un error (ej: `missing-docstring`), te recomiendo leer más sobre +el error concreto ejecutando: + +```bash +pylint --help-msg=missing-docstring +``` + +[Más sobre PyLint](http://pylint.pycqa.org/) + +### Flake8 + +Para revisar si el código sigue la guía de estilos +[PEP 8](https://www.python.org/dev/peps/pep-0008/), por favor ejecuta: + +```bash +flake8 ./src +``` + +O, si quieres ver un output más detallado, ejecuta: + +```bash +flake8 ./src --statistics --show-source --count +``` + +[Más sobre Flake8](http://flake8.pycqa.org/en/latest/) + +## Apoya al proyecto + +Puedes apoyar al proyecto a través de ❤️️ [GitHub](https://github.com/sponsors/trekhleb) o ❤️️ [Patreon](https://www.patreon.com/trekhleb). diff --git a/README.md b/README.md index e1fb02cd..6637baf7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain code examples with explanations, different use cases and links to further readings. -_Read this in_ [_Português_](README.pt-BR.md). +_Read this in_ [_Português_](README.pt-BR.md), [_Español_](README.es.md). It is a **playground** because you may change or add the code to see how it works and [test it out](#testing-the-code) using assertions. It also allows you diff --git a/README.pt-BR.md b/README.pt-BR.md index e6bd025f..1d86472e 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -5,7 +5,7 @@ > Essa é uma coleção de scripts Python dividida em [tópicos](#índice) que contém exemplos de código com explicações, diferentes usos e links para outras leituras. -_Ler em_ [_English_](README.md). +_Ler em_ [_English_](README.md), [_Español_](README.es.md). É um **playground** porque você pode fazer alterações no código para ver como ele se comporta, além de [testá-lo](#testando-o-código) usando asserções. Também é possível @@ -212,4 +212,4 @@ flake8 ./src --statistics --show-source --count --- -Traduzido por [vilmacio22](https://github.com/vilmacio22). \ No newline at end of file +Traduzido por [vilmacio22](https://github.com/vilmacio22). From 57637b9a6cf4e5fa2355be7311ebe5f4e57e14ed Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Thu, 28 Oct 2021 18:06:34 +0200 Subject: [PATCH 13/28] README fixes. --- README.es.md => README.es-ES.md | 2 +- README.md | 2 +- README.pt-BR.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename README.es.md => README.es-ES.md (99%) diff --git a/README.es.md b/README.es-ES.md similarity index 99% rename from README.es.md rename to README.es-ES.md index 60a38138..7865c822 100644 --- a/README.es.md +++ b/README.es-ES.md @@ -5,7 +5,7 @@ > Esta es una colección de scripts de Python divididos en [categorías](#contenido) que contienen ejemplos de código con sus explicaciones, diferentes usos y links a recursos adicionales. -_Lee esto en_ [_Inglés_](README.md), [_Portugués_](README.pt-BR.md). +_Lee esto en:_ [_Inglés_](README.md), [_Portugués_](README.pt-BR.md). Es un **playground** ya que puedes cambiar o añadir cosas al código para ver cómo funciona y [probarlo](#probando-el-código) usando aserciones. También puedes diff --git a/README.md b/README.md index 6637baf7..9e7398d6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain code examples with explanations, different use cases and links to further readings. -_Read this in_ [_Português_](README.pt-BR.md), [_Español_](README.es.md). +_Read this in:_ [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md). It is a **playground** because you may change or add the code to see how it works and [test it out](#testing-the-code) using assertions. It also allows you diff --git a/README.pt-BR.md b/README.pt-BR.md index 1d86472e..6487a088 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -5,7 +5,7 @@ > Essa é uma coleção de scripts Python dividida em [tópicos](#índice) que contém exemplos de código com explicações, diferentes usos e links para outras leituras. -_Ler em_ [_English_](README.md), [_Español_](README.es.md). +_Ler em:_ [_English_](README.md), [_Español_](README.es-ES.md). É um **playground** porque você pode fazer alterações no código para ver como ele se comporta, além de [testá-lo](#testando-o-código) usando asserções. Também é possível From b957147715485c42df794beb05e451ab5c049f28 Mon Sep 17 00:00:00 2001 From: Clark Chiu <49561051+ClarkChiu@users.noreply.github.com> Date: Fri, 29 Oct 2021 00:10:46 +0800 Subject: [PATCH 14/28] Translate the README.md into Traditional Chinese and add the link into original README.md (#39) Co-authored-by: Oleksii Trekhleb --- README.md | 2 + README.pt-BR.md | 2 + README.zh-TW.md | 205 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 README.zh-TW.md diff --git a/README.md b/README.md index 9e7398d6..97592bcb 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ code examples with explanations, different use cases and links to further readin _Read this in:_ [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md). +_Read this in_ [_Traditional Chinese_](README.zh-TW.md). + It is a **playground** because you may change or add the code to see how it works and [test it out](#testing-the-code) using assertions. It also allows you to [lint the code](#linting-the-code) you've wrote and check if it fits to Python code style guide. diff --git a/README.pt-BR.md b/README.pt-BR.md index 6487a088..21d8349e 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -7,6 +7,8 @@ exemplos de código com explicações, diferentes usos e links para outras leitu _Ler em:_ [_English_](README.md), [_Español_](README.es-ES.md). +_Ler em_ [_Traditional Chinese_](README.zh-TW.md). + É um **playground** porque você pode fazer alterações no código para ver como ele se comporta, além de [testá-lo](#testando-o-código) usando asserções. Também é possível [revisar o código](#revisando-o-código) que você escreveu automaticamente e verificar se ele se encaixa diff --git a/README.zh-TW.md b/README.zh-TW.md new file mode 100644 index 00000000..59a867d1 --- /dev/null +++ b/README.zh-TW.md @@ -0,0 +1,205 @@ +# 學習 Python 的練習場(Playground)和速查表(Cheatsheet) + +[![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) + +> 此專案依據 [目錄](#目錄) 分類收集了 Python 腳本,包含了程式碼範例及解釋、不同的使用情境以及衍伸閱讀連結。 + +_閱讀英文原始版本_ [_English_](README.md) + +_閱讀葡萄牙文翻譯版本_ [_Português_](README.pt-BR.md) + +此專案名稱之所以叫做 **練習場(Playground)**,是因為您可以修改或是新增程式碼至範例中去觀察程式執行流程並使用斷言關鍵字(assert)來 [測試程式](#測試程式)。同時,此專案也使用了業界常用的工具來 [檢查程式碼](#檢查程式碼),確保您所撰寫的程式碼符合官方建議的 Python 程式碼風格規範。 + +總而言之,此專案會使您的學習過程更具互動性,並幫助您從一開始學習的時候就使用高品質的程式碼。 + +此專案名稱之所以也包含了 **速查表(Cheatsheet)** 是因為您可以隨時透過此專案中的 [標準 Python 陳述式以及結構](#目錄) 回顧程式碼語法,也因為在此專案中的每個程式碼範例都使用了斷言來說明及教學,故您可以不用執行程式就看到函式/陳述式的預期輸出結果。 + +> 若對機器學習(Machine Learning)有興趣,可以參考專案原作者的另一個學習專案:🤖 [Interactive Machine Learning Experiments](https://github.com/trekhleb/machine-learning-experiments) + +## 如何使用此專案儲存庫 + +在此專案儲存庫中的每一個 Python 腳本皆為以下結構: + +```python +"""串列(Lists) <--- 此為主題名稱 + +# @詳見: https://www.learnpython.org/en/Lists <-- 此為延伸閱讀連結 + +此處可能會有針對此主題更多的詳細說明(例如:關於串列的基本使用方法) +""" + +def test_list_type(): + """此處為子主題解釋 + + 每個檔案皆包含說明該子主題的測試函式(例如:串列型態、串列方法) + """ + + # 建立串列之範例 <-- 此行是解釋下一行程式碼動作之註解 + squares = [1, 4, 9, 16, 25] + + # 串列可以被索引(indexed)及切片(sliced) + # 索引會回傳該索引位置之內容值 + assert squares[0] == 1 # <-- 利用斷言來呈現結果 + # 切片會回傳一個新的串列 + assert squares[-3:] == [9, 16, 25] # <-- 利用斷言來呈現結果 +``` + +故您可以做以下動作: + +- 找一個您想要學習或是回顧的 [主題](#目錄)。 +- 閱讀註解及/或包含於腳本文件字串(docstring)中的延伸閱讀資料(如上述之程式碼範例)。 +- 查看程式碼範例並利用斷言來展示使用範例及預期輸出。 +- 修改程式碼或新增新的斷言來了解程式運作流程。 +- [執行測試](#測試程式) 及 [檢查程式碼](#檢查程式碼) 來確認程式是否被正確撰寫及是否可以被正確執行。 + +## 目錄 + +1. **入門** + - [Python 是什麼](src/getting_started/what_is_python.md) + - [Python 語法](src/getting_started/python_syntax.md) + - [變數](src/getting_started/test_variables.py) +2. **運算子** + - [數學運算子](src/operators/test_arithmetic.py) (`+`, `-`, `*`, `/`, `//`, `%`, `**`) + - [位元運算子](src/operators/test_bitwise.py) (`&`, `|`, `^`, `>>`, `<<`, `~`) + - [指派運算子](src/operators/test_assigment.py) (`=`, `+=`, `-=`, `/=`, `//=` 等 ...) + - [比較運算子](src/operators/test_comparison.py) (`==`, `!=`, `>`, `<`, `>=`, `<=`) + - [邏輯運算子](src/operators/test_logical.py) (`and`, `or`, `not`) + - [恆等運算子](src/operators/test_identity.py) (`is`, `is not`) + - [成員存取運算子](src/operators/test_membership.py) (`in`, `not in`) +3. **資料類型** + - [數字](src/data_types/test_numbers.py)(包含布林值) + - [字串](src/data_types/test_strings.py) 及相關方法 + - [串列](src/data_types/test_lists.py) 及相關方法(包含列表構建) + - [元組](src/data_types/test_tuples.py) + - [集合](src/data_types/test_sets.py) 及相關方法 + - [字典](src/data_types/test_dictionaries.py) + - [類型轉換](src/data_types/test_type_casting.py) +4. **流程控制** + - [`if` 陳述式](src/control_flow/test_if.py) + - [`for` 陳述式](src/control_flow/test_for.py) (以及 `range()` 函式) + - [`while` 陳述式](src/control_flow/test_while.py) + - [`try` 陳述式](src/control_flow/test_try.py) + - [`break` 陳述式](src/control_flow/test_break.py) + - [`continue` 陳述式](src/control_flow/test_continue.py) +5. **函式** + - [函式定義](src/functions/test_function_definition.py)(`def` 以及 `return` 陳述式) + - [函式內變數作用範圍](src/functions/test_function_scopes.py)(`global` 以及 `nonlocal` 陳述式) + - [預設引數](src/functions/test_function_default_arguments.py) + - [關鍵字引數](src/functions/test_function_keyword_arguments.py) + - [任意引數串列](src/functions/test_function_arbitrary_arguments.py) + - [拆解引數串列](src/functions/test_function_unpacking_arguments.py)(`*` 以及 `**` 陳述式) + - [Lambda 表達式](src/functions/test_lambda_expressions.py) (`lambda` 陳述式) + - [文件字串](src/functions/test_function_documentation_string.py) + - [函式註釋](src/functions/test_function_annotations.py) + - [函式裝飾器](src/functions/test_function_decorators.py) +6. **類別** + - [類別定義](src/classes/test_class_definition.py) (`class` 陳述式) + - [類別物件](src/classes/test_class_objects.py) + - [物件實體](src/classes/test_instance_objects.py) + - [物件方法](src/classes/test_method_objects.py) + - [類別及實體變數](src/classes/test_class_and_instance_variables.py) + - [繼承](src/classes/test_inheritance.py) + - [多重繼承](src/classes/test_multiple_inheritance.py) +7. **模組** + - [模組](src/modules/test_modules.py) (`import` 陳述式) + - [套件](src/modules/test_packages.py) +8. **錯誤和例外** + - [例外處理](src/exceptions/test_handle_exceptions.py) (`try` 陳述式) + - [例外引發](src/exceptions/test_raise_exceptions.py) (`raise` 陳述式) +9. **檔案** + - [讀取和寫入](src/files/test_file_reading.py) (`with` 陳述式) + - [檔案物件方法](src/files/test_file_methods.py) +10. **附加內容** + - [`pass` 陳述式](src/additions/test_pass.py) + - [生成器](src/additions/test_generators.py) (`yield` 陳述式) +11. **標準函式庫簡介** + - [串列化](src/standard_libraries/test_json.py) (`json` 函式庫) + - [檔案萬用字元](src/standard_libraries/test_glob.py) (`glob` 函式庫) + - [字串規則比對](src/standard_libraries/test_re.py) (`re` 函式庫) + - [數學運算](src/standard_libraries/test_math.py) (`math`, `random`, `statistics` 函式庫) + - [日期和時間](src/standard_libraries/test_datetime.py) (`datetime` 函式庫) + - [資料壓縮](src/standard_libraries/test_zlib.py) (`zlib` 函式庫) + +## 使用此專案必備條件 + +**安裝 Python** + +確認您已安裝 [Python3](https://realpython.com/installing-python/) 在您的電腦上。 + +您可能會想要使用標準 Python 函式庫所提供的 [虛擬環境](https://docs.python.org/3/library/venv.html) 功能在專案目錄中建立虛擬環境來佈署 Python 程式、pip 程式以及安裝所有需要的套件,藉此來避免作業系統中 Python 版本及相依性的混亂。 + +根據您的安裝方法,您可能可以通過以下方式執行 Python 3 直譯器:執行 `python` 或 `python3` 命令。pip 套件管理器執行方式也是如此:執行 `pip` 或 `pip3`。 + +您可以使用以下命令來確認 Python 版本: + +```bash +python --version +``` + +此專案儲存庫中的所有程式碼皆是基於 Python **3**。 + +**安裝相依性套件** + +透過以下命令安裝此專案需要的相依性套件: + +```bash +pip install -r requirements.txt +``` + +## 測試程式 + +此專案使用 [pytest](https://docs.pytest.org/en/latest/) 測試框架來執行程式碼測試。 + +您可以新增以 `test_` 為開頭的檔案/函式來新增測試。(例如:`test_topic.py` 檔案內有 `def test_sub_topic()` 測試函式) + +請從專案根目錄下使用以下命令來執行所有測試: + +```bash +pytest +``` + +您也可以使用以下命令執行特定測試: + +```bash +pytest ./path/to/the/test_file.py +``` + +## 檢查程式碼 + +此專案使用 [pylint](http://pylint.pycqa.org/) 以及 [flake8](http://flake8.pycqa.org/en/latest/) 函式庫來執行程式碼檢查。 + +### PyLint + +檢查撰寫之程式碼是否符合 [PEP 8](https://www.python.org/dev/peps/pep-0008/) 風格規範,請執行以下命令: + +```bash +pylint ./src/ +``` + +若此檢查工具偵測到錯誤(例如:`missing-docstring`),您可以使用以下命令查看特定錯誤之詳細說明: + +```bash +pylint --help-msg=missing-docstring +``` + +[更多關於 PyLint](http://pylint.pycqa.org/) + +### Flake8 + +檢查撰寫之程式碼是否符合 [PEP 8](https://www.python.org/dev/peps/pep-0008/) 風格規範,請執行以下命令: + +```bash +flake8 . /src +``` + +若您希望得到更多詳細的輸出,您可以加上以下參數再執行此工具: + +```bash +flake8 . /src --statistics --show-source --count +``` + +[更多關於 Flake8](http://flake8.pycqa.org/en/latest/) + +## 支持此專案 + +您可以透過 ❤️️ [GitHub](https://github.com/sponsors/trekhleb) 或 ❤️️ [Patreon](https://www.patreon.com/trekhleb) 支持原作者專案 \ No newline at end of file From a9352e91891f765a4cd25e25007d8c9513ad5f8d Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Thu, 28 Oct 2021 18:12:54 +0200 Subject: [PATCH 15/28] README fixes. --- README.md | 4 +--- README.zh-TW.md | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 97592bcb..82582d3e 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,7 @@ > This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain code examples with explanations, different use cases and links to further readings. -_Read this in:_ [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md). - -_Read this in_ [_Traditional Chinese_](README.zh-TW.md). +_Read this in:_ [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md), [_Traditional Chinese_](README.zh-TW.md). It is a **playground** because you may change or add the code to see how it works and [test it out](#testing-the-code) using assertions. It also allows you diff --git a/README.zh-TW.md b/README.zh-TW.md index 59a867d1..035b786c 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -4,9 +4,7 @@ > 此專案依據 [目錄](#目錄) 分類收集了 Python 腳本,包含了程式碼範例及解釋、不同的使用情境以及衍伸閱讀連結。 -_閱讀英文原始版本_ [_English_](README.md) - -_閱讀葡萄牙文翻譯版本_ [_Português_](README.pt-BR.md) +_閱讀英文原始版本:_ [_English_](README.md), [_Português_](README.pt-BR.md). 此專案名稱之所以叫做 **練習場(Playground)**,是因為您可以修改或是新增程式碼至範例中去觀察程式執行流程並使用斷言關鍵字(assert)來 [測試程式](#測試程式)。同時,此專案也使用了業界常用的工具來 [檢查程式碼](#檢查程式碼),確保您所撰寫的程式碼符合官方建議的 Python 程式碼風格規範。 @@ -202,4 +200,4 @@ flake8 . /src --statistics --show-source --count ## 支持此專案 -您可以透過 ❤️️ [GitHub](https://github.com/sponsors/trekhleb) 或 ❤️️ [Patreon](https://www.patreon.com/trekhleb) 支持原作者專案 \ No newline at end of file +您可以透過 ❤️️ [GitHub](https://github.com/sponsors/trekhleb) 或 ❤️️ [Patreon](https://www.patreon.com/trekhleb) 支持原作者專案 From f3ca935e6105ab926ba53556fd88bbfd9d6cc04f Mon Sep 17 00:00:00 2001 From: Adam Stiefel <80831741+adamstiefel@users.noreply.github.com> Date: Thu, 28 Oct 2021 12:15:16 -0400 Subject: [PATCH 16/28] Change verb form (#42) Change from making to make. Given the context of the pledge, the proper verb form appears to be "make". Co-authored-by: Oleksii Trekhleb --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index c7a64f37..4f66f4ae 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,7 +2,7 @@ ## Our Pledge -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards From 8f215a8c71484a38f0bd7b94e8446df156324724 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Thu, 28 Oct 2021 18:17:35 +0200 Subject: [PATCH 17/28] README fixes. --- README.es-ES.md | 2 +- README.md | 2 +- README.pt-BR.md | 4 +--- README.zh-TW.md | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.es-ES.md b/README.es-ES.md index 7865c822..0d6e5771 100644 --- a/README.es-ES.md +++ b/README.es-ES.md @@ -5,7 +5,7 @@ > Esta es una colección de scripts de Python divididos en [categorías](#contenido) que contienen ejemplos de código con sus explicaciones, diferentes usos y links a recursos adicionales. -_Lee esto en:_ [_Inglés_](README.md), [_Portugués_](README.pt-BR.md). +> _Lee esto en:_ [_Inglés_](README.md), [_Portugués_](README.pt-BR.md), _Traditional Chinese_](README.zh-TW.md). Es un **playground** ya que puedes cambiar o añadir cosas al código para ver cómo funciona y [probarlo](#probando-el-código) usando aserciones. También puedes diff --git a/README.md b/README.md index 82582d3e..af3242d5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ > This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain code examples with explanations, different use cases and links to further readings. -_Read this in:_ [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md), [_Traditional Chinese_](README.zh-TW.md). +> _Read this in:_ [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md), [_Traditional Chinese_](README.zh-TW.md). It is a **playground** because you may change or add the code to see how it works and [test it out](#testing-the-code) using assertions. It also allows you diff --git a/README.pt-BR.md b/README.pt-BR.md index 21d8349e..4839e9ab 100644 --- a/README.pt-BR.md +++ b/README.pt-BR.md @@ -5,9 +5,7 @@ > Essa é uma coleção de scripts Python dividida em [tópicos](#índice) que contém exemplos de código com explicações, diferentes usos e links para outras leituras. -_Ler em:_ [_English_](README.md), [_Español_](README.es-ES.md). - -_Ler em_ [_Traditional Chinese_](README.zh-TW.md). +> _Ler em:_ [_English_](README.md), [_Español_](README.es-ES.md), [_Traditional Chinese_](README.zh-TW.md). É um **playground** porque você pode fazer alterações no código para ver como ele se comporta, além de [testá-lo](#testando-o-código) usando asserções. Também é possível diff --git a/README.zh-TW.md b/README.zh-TW.md index 035b786c..689c1ec8 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -4,7 +4,7 @@ > 此專案依據 [目錄](#目錄) 分類收集了 Python 腳本,包含了程式碼範例及解釋、不同的使用情境以及衍伸閱讀連結。 -_閱讀英文原始版本:_ [_English_](README.md), [_Português_](README.pt-BR.md). +> _閱讀英文原始版本:_ [_English_](README.md), [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md). 此專案名稱之所以叫做 **練習場(Playground)**,是因為您可以修改或是新增程式碼至範例中去觀察程式執行流程並使用斷言關鍵字(assert)來 [測試程式](#測試程式)。同時,此專案也使用了業界常用的工具來 [檢查程式碼](#檢查程式碼),確保您所撰寫的程式碼符合官方建議的 Python 程式碼風格規範。 From 3f1801185ff2c40354bc2ed4220319e11ba8c922 Mon Sep 17 00:00:00 2001 From: Henrique Tsuyoshi Yara Date: Sun, 23 Jan 2022 17:59:29 -0300 Subject: [PATCH 18/28] Change some typos, words and improve reading (#56) * style(test_generators.py): change i for _ in loop * style(test_multiple_inheritance.py): better identation * style(test_function_arbitraty_arguments.py): fix typo * style(test_class_and_instance_variables.py): fix comment * style(test_class_and_instance_variables.py): fix typo Co-authored-by: Oleksii Trekhleb --- src/additions/test_generators.py | 2 +- src/classes/test_class_and_instance_variables.py | 2 +- src/classes/test_multiple_inheritance.py | 4 ++-- src/functions/test_function_arbitrary_arguments.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/additions/test_generators.py b/src/additions/test_generators.py index ff3bce26..6b2f2736 100644 --- a/src/additions/test_generators.py +++ b/src/additions/test_generators.py @@ -23,7 +23,7 @@ def lottery(): """ # returns first 3 random numbers between 1 and 10 # pylint: disable=unused-variable - for i in range(3): + for _ in range(3): yield random.randint(1, 10) # returns a 4th number between 10 and 20 diff --git a/src/classes/test_class_and_instance_variables.py b/src/classes/test_class_and_instance_variables.py index c4004d79..d33ff2e6 100644 --- a/src/classes/test_class_and_instance_variables.py +++ b/src/classes/test_class_and_instance_variables.py @@ -72,7 +72,7 @@ def __init__(self, name): def add_trick(self, trick): """Add trick to the dog - This function illustrate mistaken use of mutable class variable tricks (see below). + This function illustrate a correct use of mutable class variable tricks (see below). """ self.tricks.append(trick) diff --git a/src/classes/test_multiple_inheritance.py b/src/classes/test_multiple_inheritance.py index 2ad73f8d..e3d41529 100644 --- a/src/classes/test_multiple_inheritance.py +++ b/src/classes/test_multiple_inheritance.py @@ -41,8 +41,8 @@ def get_date(self): class CalendarClock(Clock, Calendar): """Class that uses multiple inheritance. - For most purposes, in the simplest cases, you can think of the search for attributes i - nherited from a parent class as depth-first, left-to-right, not searching twice in the same + For most purposes, in the simplest cases, you can think of the search for attributes + inherited from a parent class as depth-first, left-to-right, not searching twice in the same class where there is an overlap in the hierarchy. Thus, if an attribute is not found in CalendarClock, it is searched for in Clock, then (recursively) in the base classes of Clock, and if it was not found there, it was searched for in Calendar, and so on. diff --git a/src/functions/test_function_arbitrary_arguments.py b/src/functions/test_function_arbitrary_arguments.py index b3f36627..6853a178 100644 --- a/src/functions/test_function_arbitrary_arguments.py +++ b/src/functions/test_function_arbitrary_arguments.py @@ -16,7 +16,7 @@ def test_function_arbitrary_arguments(): # containing the positional arguments beyond the formal parameter list. # (*name must occur before **name.) For example, if we define a function like this: def test_function(first_param, *arguments): - """This function accepts its arguments through "arguments" tuple amd keywords dictionary.""" + """This function accepts its arguments through "arguments" tuple and keywords dictionary.""" assert first_param == 'first param' assert arguments == ('second param', 'third param') From 6ff6be8e0d825c1dc06056df92f25a6903ce2dd8 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 24 Jan 2022 05:01:18 +0800 Subject: [PATCH 19/28] fix typo "amd" -> "and" (#61) Co-authored-by: Oleksii Trekhleb --- src/functions/test_function_keyword_arguments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/test_function_keyword_arguments.py b/src/functions/test_function_keyword_arguments.py index 65d066c1..7b6ff1c3 100644 --- a/src/functions/test_function_keyword_arguments.py +++ b/src/functions/test_function_keyword_arguments.py @@ -102,7 +102,7 @@ def function_with_one_argument(number): # containing the positional arguments beyond the formal parameter list. # (*name must occur before **name.) For example, if we define a function like this: def test_function(first_param, *arguments, **keywords): - """This function accepts its arguments through "arguments" tuple amd keywords dictionary.""" + """This function accepts its arguments through "arguments" tuple and keywords dictionary.""" assert first_param == 'first param' assert arguments == ('second param', 'third param') assert keywords == { From 5e936a75c3ba15ddc4db055f161a814b6d77dcd7 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 24 Jan 2022 05:02:08 +0800 Subject: [PATCH 20/28] no **keywords dictionary parameters (#62) Co-authored-by: Oleksii Trekhleb --- src/functions/test_function_arbitrary_arguments.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions/test_function_arbitrary_arguments.py b/src/functions/test_function_arbitrary_arguments.py index 6853a178..2b00d176 100644 --- a/src/functions/test_function_arbitrary_arguments.py +++ b/src/functions/test_function_arbitrary_arguments.py @@ -16,7 +16,7 @@ def test_function_arbitrary_arguments(): # containing the positional arguments beyond the formal parameter list. # (*name must occur before **name.) For example, if we define a function like this: def test_function(first_param, *arguments): - """This function accepts its arguments through "arguments" tuple and keywords dictionary.""" + """This function accepts its arguments through "arguments" tuple""" assert first_param == 'first param' assert arguments == ('second param', 'third param') From 212ca88fa170a0b89f625b4f40c9734a93d43cc0 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Sat, 12 Mar 2022 17:44:14 +0100 Subject: [PATCH 21/28] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index af3242d5..edb4d6dd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # Playground and Cheatsheet for Learning Python +> 🇺🇦 UKRAINE [IS BEING ATTACKED](https://twitter.com/MFA_Ukraine) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED. +> - Help Ukraine via [National Bank of Ukraine](https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi) +> - Help Ukraine via [SaveLife](https://savelife.in.ua/en/donate/) fund [![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) From 28da1e44d02d489631903612479d14d910532317 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Sat, 12 Mar 2022 17:46:46 +0100 Subject: [PATCH 22/28] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index edb4d6dd..16301256 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ > 🇺🇦 UKRAINE [IS BEING ATTACKED](https://twitter.com/MFA_Ukraine) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED. > - Help Ukraine via [National Bank of Ukraine](https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi) > - Help Ukraine via [SaveLife](https://savelife.in.ua/en/donate/) fund +> - More info on [war.ukraine.ua](https://war.ukraine.ua/) [![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) From 756fbfefb54d0c5f0e848a0ccfc3bb05f6a83ef8 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Sat, 2 Jul 2022 17:50:47 +0200 Subject: [PATCH 23/28] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16301256..ed382170 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Playground and Cheatsheet for Learning Python > 🇺🇦 UKRAINE [IS BEING ATTACKED](https://twitter.com/MFA_Ukraine) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED. > - Help Ukraine via [National Bank of Ukraine](https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi) -> - Help Ukraine via [SaveLife](https://savelife.in.ua/en/donate/) fund +> - Help Ukraine via [SaveLife](https://savelife.in.ua/en/donate-en/) fund > - More info on [war.ukraine.ua](https://war.ukraine.ua/) [![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) From 684b6e1072519e73f7aa4d42f98ece4cabb1efe8 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Wed, 21 Sep 2022 09:11:01 +0200 Subject: [PATCH 24/28] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed382170..b183acab 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Playground and Cheatsheet for Learning Python -> 🇺🇦 UKRAINE [IS BEING ATTACKED](https://twitter.com/MFA_Ukraine) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED. + +> 🇺🇦 UKRAINE [IS BEING ATTACKED](https://war.ukraine.ua/) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED. > - Help Ukraine via [National Bank of Ukraine](https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi) > - Help Ukraine via [SaveLife](https://savelife.in.ua/en/donate-en/) fund -> - More info on [war.ukraine.ua](https://war.ukraine.ua/) +> - More info on [war.ukraine.ua](https://war.ukraine.ua/) and [MFA of Ukraine](https://twitter.com/MFA_Ukraine) [![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) From 4242402e7d4eed57d997cd764566409c65c7787c Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Wed, 21 Sep 2022 09:13:28 +0200 Subject: [PATCH 25/28] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b183acab..40701a3d 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ > - Help Ukraine via [SaveLife](https://savelife.in.ua/en/donate-en/) fund > - More info on [war.ukraine.ua](https://war.ukraine.ua/) and [MFA of Ukraine](https://twitter.com/MFA_Ukraine) +
+ [![Build Status](https://travis-ci.org/trekhleb/learn-python.svg?branch=master)](https://travis-ci.org/trekhleb/learn-python) > This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain From 72fa79eaa66d0bbb3487ce65194b5ea2eaea2e41 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 21 Oct 2022 22:23:13 +0200 Subject: [PATCH 26/28] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 40701a3d..862e42fe 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ Each Python script in this repository has the following structure: ```python """Lists <--- Name of the topic here +## Author + +- [@trekhleb](https://trekhleb.dev) + # @see: https://www.learnpython.org/en/Lists <-- Link to further readings goes here Here might go more detailed explanation of the current topic (i.e. general info about Lists). From 8344a56dacfef5405cf491bfc0eb3337500a0d56 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 21 Oct 2022 22:24:27 +0200 Subject: [PATCH 27/28] Update README.md --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 862e42fe..2ea49895 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,6 @@ Each Python script in this repository has the following structure: ```python """Lists <--- Name of the topic here -## Author - -- [@trekhleb](https://trekhleb.dev) - # @see: https://www.learnpython.org/en/Lists <-- Link to further readings goes here Here might go more detailed explanation of the current topic (i.e. general info about Lists). @@ -228,6 +224,6 @@ flake8 ./src --statistics --show-source --count [More about Flake8](http://flake8.pycqa.org/en/latest/) -## Supporting the project +## Author -You may support this project via ❤️️ [GitHub](https://github.com/sponsors/trekhleb) or ❤️️ [Patreon](https://www.patreon.com/trekhleb). +- [@trekhleb](https://trekhleb.dev) From 52c3a655cc2efd5ac01004f6f529c3262812a84e Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 21 Jul 2023 20:09:00 +0200 Subject: [PATCH 28/28] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ea49895..f53cdf8f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # Playground and Cheatsheet for Learning Python > 🇺🇦 UKRAINE [IS BEING ATTACKED](https://war.ukraine.ua/) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED. -> - Help Ukraine via [National Bank of Ukraine](https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi) -> - Help Ukraine via [SaveLife](https://savelife.in.ua/en/donate-en/) fund +> - Help Ukraine via: +> - [Serhiy Prytula Charity Foundation](https://prytulafoundation.org/en/) +> - [Come Back Alive Charity Foundation](https://savelife.in.ua/en/donate-en/) +> - [National Bank of Ukraine](https://bank.gov.ua/en/news/all/natsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi) > - More info on [war.ukraine.ua](https://war.ukraine.ua/) and [MFA of Ukraine](https://twitter.com/MFA_Ukraine)