mirror of
https://github.com/satwikkansal/wtfpython
synced 2024-06-10 06:59:50 +02:00
Compare commits
226 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d2673bba08 | ||
|
be4811aeb7 | ||
|
77af92f780 | ||
|
394fa09b07 | ||
|
b251f1b150 | ||
|
c7f3849c1a | ||
|
d70bf71cb6 | ||
|
8db7d48ad6 | ||
|
39595fc35f | ||
|
b6fd12efa2 | ||
|
0ec5939713 | ||
|
19fba38556 | ||
|
16628ba071 | ||
|
b1684aaf39 | ||
|
6f35f00461 | ||
|
a2c5a17ca8 | ||
|
fcb70ba7b9 | ||
|
9687de2a67 | ||
|
d0dd3ad2b7 | ||
|
5bbdcdd5a5 | ||
|
2c623dd33a | ||
|
f0afccc347 | ||
|
d7d7e970d7 | ||
|
05ad6cf2af | ||
|
f71b997a45 | ||
|
9e2508ae6a | ||
|
4b4951d755 | ||
|
00e420fc51 | ||
|
ebe5f59a9d | ||
|
551b251c05 | ||
|
eab5d5968e | ||
|
a5f1258275 | ||
|
b5c20d02ea | ||
|
3b9d9bdcd1 | ||
|
be9c3bb0ae | ||
|
193c839163 | ||
|
664bb038d4 | ||
|
e2d0be0e2a | ||
|
8ab55b7393 | ||
|
124b0f027d | ||
|
662b720b5c | ||
|
039adfa04a | ||
|
f84272fc5c | ||
|
8f60bc1d0b | ||
|
bbb086a521 | ||
|
2043112a9d | ||
|
0d28d47f08 | ||
|
a25fe26adc | ||
|
40503d5ac5 | ||
|
c2dd151ed5 | ||
|
7ce56da1d8 | ||
|
473e4229f2 | ||
|
3df9d0e4e3 | ||
|
e8cd593e62 | ||
|
2aa7b37540 | ||
|
b1a8aadd70 | ||
|
eccd68a4bd | ||
|
3fc9e9e028 | ||
|
c125f25fb5 | ||
|
f96f5117c5 | ||
|
58de881f93 | ||
|
f2b1d7e8c2 | ||
|
495c840254 | ||
|
51d13b87cf | ||
|
ecaab6dca1 | ||
|
972d1334fb | ||
|
a0069d842e | ||
|
8a1536986f | ||
|
5eeb1053aa | ||
|
293575b7c4 | ||
|
191ea8343b | ||
|
6e246d1487 | ||
|
a32eaca58f | ||
|
446a3a09bb | ||
|
4576463fcc | ||
|
361ac5f49b | ||
|
497b9de72b | ||
|
259fb23c7b | ||
|
654da92e88 | ||
|
83bdff8e33 | ||
|
47fa96c31a | ||
|
2840050acb | ||
|
a7985b9edc | ||
|
e2d6ee66cc | ||
|
c91a6073fb | ||
|
86140390ad | ||
|
b5b8b83c0a | ||
|
489ccb18a7 | ||
|
57987cc9d5 | ||
|
86e78697fb | ||
|
1b1b9d4b70 | ||
|
19d4b07515 | ||
|
ab82f9647c | ||
|
f32e9d36e3 | ||
|
6010b97d90 | ||
|
acfcfa8808 | ||
|
ccf5be1a6f | ||
|
a50839656c | ||
|
f5f5208b12 | ||
|
ea1e228407 | ||
|
d8258dbc96 | ||
|
6a4cd34413 | ||
|
feeb410009 | ||
|
6213399144 | ||
|
d3a25fa14e | ||
|
e9a49a5527 | ||
|
be377779b6 | ||
|
fe9ed47217 | ||
|
00c5503712 | ||
|
cd4d7c0e34 | ||
|
c8f300fd09 | ||
|
205c9ede01 | ||
|
f4f501a230 | ||
|
043b83a722 | ||
|
2e2d65a9ec | ||
|
086be4ed19 | ||
|
9fc6db6215 | ||
|
897b915f11 | ||
|
6642876c64 | ||
|
b89710a415 | ||
|
aaa74c46a7 | ||
|
1787b50422 | ||
|
5525591601 | ||
|
bfccb718de | ||
|
95a87484c5 | ||
|
6e187cf84b | ||
|
d6ba3a66a3 | ||
|
f0bd1cb481 | ||
|
70c03e9801 | ||
|
9d0ad9ed98 | ||
|
48256e1fe8 | ||
|
de4b851c72 | ||
|
048a620502 | ||
|
2bc1cd61c1 | ||
|
d06fcbff1b | ||
|
c954b71f67 | ||
|
314de9a30b | ||
|
f13b98e6d5 | ||
|
902ca179eb | ||
|
9c42b920ad | ||
|
bb8ce63f68 | ||
|
ac63a4fb3a | ||
|
c824ed7813 | ||
|
e5b519149d | ||
|
435fd5f49e | ||
|
f082e9f22a | ||
|
33bcfa744a | ||
|
7525e800b8 | ||
|
9b3f86958a | ||
|
d4ad5a0643 | ||
|
9e28e00123 | ||
|
27b66b4f31 | ||
|
19e6b7da57 | ||
|
be2d537a05 | ||
|
7d06e7b5c1 | ||
|
a3baf043bd | ||
|
03a035a89d | ||
|
87906b9b2f | ||
|
ee0696b676 | ||
|
f72d7325fa | ||
|
ee70d52fe4 | ||
|
f97cbdd919 | ||
|
098d71f348 | ||
|
0b74f9ba5d | ||
|
7457ffb848 | ||
|
3ba87fea65 | ||
|
32f14a7e16 | ||
|
14600fd19b | ||
|
5edef33cae | ||
|
9ff40de544 | ||
|
0684777fa3 | ||
|
f735fe3116 | ||
|
669ff8c30e | ||
|
67f743eddd | ||
|
78cb5f39f5 | ||
|
e9b04d33f7 | ||
|
733061f90d | ||
|
184df9f99d | ||
|
a4af8a4e0c | ||
|
50265e91fc | ||
|
6cebc952c3 | ||
|
bd7cd4334c | ||
|
97c10e6fda | ||
|
8e6c850f30 | ||
|
e74ccb79d0 | ||
|
daf156abf5 | ||
|
16c90f9b24 | ||
|
3e99005ae4 | ||
|
8370f3a3b9 | ||
|
f20be4cfc4 | ||
|
00a1228ca3 | ||
|
de113d2491 | ||
|
ffb1599458 | ||
|
5f8067df42 | ||
|
30a6623ccd | ||
|
83cac75f41 | ||
|
d1a4144143 | ||
|
3e98cf1ceb | ||
|
43679ebd1e | ||
|
0d65c00bb6 | ||
|
255b9a574b | ||
|
68f6e0217c | ||
|
3d64252310 | ||
|
185d60c1b6 | ||
|
1b3b2e6c71 | ||
|
f98bd4363f | ||
|
2c910351b7 | ||
|
9a2718ae3a | ||
|
183e0d9ee5 | ||
|
2f2fcf87bc | ||
|
99280f57a0 | ||
|
7c85a73442 | ||
|
e4f340281c | ||
|
6c0ed6e7c5 | ||
|
dcc2e6a3d8 | ||
|
a1b4f8d521 | ||
|
328168c86f | ||
|
73a1248d04 | ||
|
a39792bd4b | ||
|
bd45175405 | ||
|
438f52c3e9 | ||
|
b3387c9dc7 | ||
|
ad39ef8625 | ||
|
df8baf9941 | ||
|
e35642ed05 | ||
|
f8aa17c8ba |
40
CONTRIBUTING.md
vendored
40
CONTRIBUTING.md
vendored
|
@ -1,12 +1,8 @@
|
|||
All kinds of patches are welcome. Feel free to even suggest some catchy and funny titles for the existing Examples. The goal is to make this collection as interesting to read as possible.
|
||||
All kinds of patches are welcome. Feel free to even suggest some catchy and funny titles for the existing Examples. The goal is to make this collection as interesting to read as possible. Here are a few ways through which you can contribute,
|
||||
|
||||
If you are interested in translating the project to another language (some people have done that in the past), please feel free to open up an issue, and let me know if you need any kind of help.
|
||||
|
||||
If the changes you suggest are significant, filing an issue before submitting the actual patch will be appreciated. If you'd like to work on the issue (highly encouraged), you can mention that you're interested in working on it while creating the issue and get assigned to it.
|
||||
|
||||
If you're adding a new example, please do create an issue to discuss it before submitting a patch.
|
||||
|
||||
You can use the following template for adding a new example:
|
||||
- If you are interested in translating the project to another language (some people have done that in the past), please feel free to open up an issue, and let me know if you need any kind of help.
|
||||
- If the changes you suggest are significant, filing an issue before submitting the actual patch will be appreciated. If you'd like to work on the issue (highly encouraged), you can mention that you're interested in working on it while creating the issue and get assigned to it.
|
||||
- If you're adding a new example, it is highly recommended to create an issue to discuss it before submitting a patch. You can use the following template for adding a new example:
|
||||
|
||||
<pre>
|
||||
### ▶ Some fancy Title *
|
||||
|
@ -29,7 +25,7 @@ Probably unexpected output
|
|||
```py
|
||||
Setting up examples for clarification (if necessary)
|
||||
```
|
||||
**Outupt:**
|
||||
**Output:**
|
||||
```py
|
||||
>>> trigger # some example that makes it easy to unveil the magic
|
||||
# some justified output
|
||||
|
@ -40,6 +36,28 @@ Probably unexpected output
|
|||
|
||||
Few things that you can consider while writing an example,
|
||||
|
||||
- Try to be consistent with the namings and the values you use with the variables. For instance, most variable names in the project are along the lines of `some_string`, `some_list`, `some_dict`, etc. You'd see a lot of `x`s for single letter variable names, and `"wtf"` as values for strings. There's strictly enforced scheme in the project, but you can take a glance at other examples to get a gist.
|
||||
- If you are choosing to submit a new example without creating an issue and discussing, please check the project to make sure there aren't similar examples already.
|
||||
- Try to be consistent with the namings and the values you use with the variables. For instance, most variable names in the project are along the lines of `some_string`, `some_list`, `some_dict`, etc. You'd see a lot of `x`s for single letter variable names, and `"wtf"` as values for strings. There's no strictly enforced scheme in the project as such, but you can take a glance at other examples to get a gist.
|
||||
- Try to be as creative as possible to add that element of "surprise" in the setting up part of an example. Sometimes this may mean writing a snippet a sane programmer would never write.
|
||||
- Also, please don't forget to add your name to the [contributors list](/CONTRIBUTING.md).
|
||||
- Also, feel free to add your name to the [contributors list](/CONTRIBUTORS.md).
|
||||
|
||||
**Some FAQs**
|
||||
|
||||
What is is this after every snippet title (###) in the README: <!-- Example ID: 30f1d3fc-e267-4b30-84ef-4d9e7091ac1a --->? Should it be added manually or can it be ignored when creating new snippets?
|
||||
|
||||
That's a random UUID, it is used to keep identify the examples across multiple translations of the project. As a contributor, you don't have to worry about behind the scenes of how it is used, you just have to add a new random UUID to new examples in that format.
|
||||
|
||||
Where should new snippets be added? Top/bottom of the section, doesn't ?
|
||||
|
||||
There are multiple things that are considered to decide the order (the dependency on the other examples, difficulty level, category, etc). I'd suggest simply adding the new example at the bottom of a section you find more fitting (or just add it to the Miscellaneous section). Its order will be taken care of in future revisions.
|
||||
|
||||
What's the difference between the sections (the first two feel very similar)?
|
||||
|
||||
The section "Strain your brain" contains more contrived examples that you may not really encounter in real life, whereas the section "Slippery Slopes" contains examples that have the potential to be encountered more frequently while programming.
|
||||
|
||||
Before the table of contents it says that markdown-toc -i README.md --maxdepth 3 was used to create it. The pip package markdown-toc does not contain either -i or --maxdepth flags. Which package is meant, or what version of that package?
|
||||
Should the new table of contents entry for the snippet be created with the above command or created manually (in case the above command does more than only add the entry)?
|
||||
|
||||
We use the [markdown-toc](https://www.npmjs.com/package/markdown-toc) npm package to generate ToC. It has some issues with special characters though (I'm not sure if it's fixed yet). More often than not, I just end up inserting the toc link manually at the right place. The tool is handy when I have to big reordering, otherwise just updating toc manually is more convenient imo.
|
||||
|
||||
If you have any questions feel free to ask on [this issue](https://github.com/satwikkansal/wtfpython/issues/269) (thanks to [@LiquidFun](https://github.com/LiquidFun) for starting it).
|
||||
|
|
16
CONTRIBUTORS.md
vendored
16
CONTRIBUTORS.md
vendored
|
@ -18,10 +18,24 @@ Following are the wonderful people (in no specific order) who have contributed t
|
|||
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [#112](https://github.com/satwikkansal/wtfpython/issues/112) |
|
||||
| mishaturnbull | [mishaturnbull](https://github.com/mishaturnbull) | [#108](https://github.com/satwikkansal/wtfpython/issues/108) |
|
||||
| MuseBoy | [MuseBoy](https://github.com/MuseBoy) | [#101](https://github.com/satwikkansal/wtfpython/issues/101) |
|
||||
| Ghost account | N/A | [#96](https://github.com/satwikkansal/wtfpython/issues/96)
|
||||
| Ghost account | N/A | [#96](https://github.com/satwikkansal/wtfpython/issues/96) |
|
||||
| koddo | [koddo](https://github.com/koddo) | [#80](https://github.com/satwikkansal/wtfpython/issues/80), [#73](https://github.com/satwikkansal/wtfpython/issues/73) |
|
||||
| jab | [jab](https://github.com/jab) | [#77](https://github.com/satwikkansal/wtfpython/issues/77) |
|
||||
| Jongy | [Jongy](https://github.com/Jongy) | [#208](https://github.com/satwikkansal/wtfpython/issues/208), [#210](https://github.com/satwikkansal/wtfpython/issues/210), [#233](https://github.com/satwikkansal/wtfpython/issues/233) |
|
||||
| Diptangsu Goswami | [diptangsu](https://github.com/diptangsu) | [#193](https://github.com/satwikkansal/wtfpython/issues/193) |
|
||||
| Charles | [charles-l](https://github.com/charles-l) | [#245](https://github.com/satwikkansal/wtfpython/issues/245) |
|
||||
| LiquidFun | [LiquidFun](https://github.com/LiquidFun) | [#267](https://github.com/satwikkansal/wtfpython/issues/267) |
|
||||
|
||||
---
|
||||
|
||||
**Translations**
|
||||
|
||||
| Translator | Github | Language |
|
||||
|-------------|--------|--------|
|
||||
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [Chinese](https://github.com/leisurelicht/wtfpython-cn) |
|
||||
| vuduclyunitn | [vuduclyunitn](https://github.com/vuduclyunitn) | [Vietnamese](https://github.com/vuduclyunitn/wtfptyhon-vi) |
|
||||
| José De Freitas | [JoseDeFreitas](https://github.com/JoseDeFreitas) | [Spanish](https://github.com/JoseDeFreitas/wtfpython-es) |
|
||||
| Vadim Nifadev | [nifadyev](https://github.com/nifadyev) | [Russian](https://github.com/satwikkansal/wtfpython/tree/master/translations/ru-russian) |
|
||||
|
||||
Thank you all for your time and making wtfpython more awesome! :smile:
|
||||
|
||||
|
|
BIN
images/expanding-brain-meme.jpg
vendored
Normal file
BIN
images/expanding-brain-meme.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 113 KiB |
BIN
images/logo-dark.png
vendored
Normal file
BIN
images/logo-dark.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
|
@ -55,6 +55,12 @@ That being said, most of the examples do work as expected. If you face any troub
|
|||
|
||||
|
||||
def generate_code_block(statements, output):
|
||||
"""
|
||||
Generates a code block that executes the given statements.
|
||||
|
||||
:param statements: The list of statements to execute.
|
||||
:type statements: list(str)
|
||||
"""
|
||||
global sequence_num
|
||||
result = {
|
||||
"type": "code",
|
||||
|
@ -67,6 +73,9 @@ def generate_code_block(statements, output):
|
|||
|
||||
|
||||
def generate_markdown_block(lines):
|
||||
"""
|
||||
Generates a markdown block from a list of lines.
|
||||
"""
|
||||
global sequence_num
|
||||
result = {
|
||||
"type": "markdown",
|
||||
|
@ -85,6 +94,12 @@ def is_interactive_statement(line):
|
|||
|
||||
|
||||
def parse_example_parts(lines, title, current_line):
|
||||
"""
|
||||
Parse the given lines and return a dictionary with two keys:
|
||||
build_up, which contains all the text before an H4 (explanation) is encountered,
|
||||
and
|
||||
explanation, which contains all the text after build_up until --- or another H3 is encountered.
|
||||
"""
|
||||
parts = {
|
||||
"build_up": [],
|
||||
"explanation": []
|
||||
|
@ -191,6 +206,14 @@ def remove_from_beginning(tokens, line):
|
|||
|
||||
|
||||
def inspect_and_sanitize_code_lines(lines):
|
||||
"""
|
||||
Remove lines from the beginning of a code block that are not statements.
|
||||
|
||||
:param lines: A list of strings, each representing a line in the code block.
|
||||
:returns is_print_present, sanitized_lines: A boolean indicating whether print was present in the original code and a list of strings representing
|
||||
sanitized lines. The latter may be an empty list if all input lines were removed as comments or whitespace (and thus did not contain any statements).
|
||||
This function does not remove blank lines at the end of `lines`.
|
||||
"""
|
||||
tokens_to_remove = STATEMENT_PREFIXES
|
||||
result = []
|
||||
is_print_present = False
|
||||
|
@ -203,6 +226,23 @@ def inspect_and_sanitize_code_lines(lines):
|
|||
|
||||
|
||||
def convert_to_cells(cell_contents, read_only):
|
||||
"""
|
||||
Converts a list of dictionaries containing markdown and code cells into a Jupyter notebook.
|
||||
|
||||
:param cell_contents: A list of dictionaries, each
|
||||
dictionary representing either a markdown or code cell. Each dictionary should have the following keys: "type", which is either "markdown" or "code",
|
||||
and "value". The value for type = 'markdown' is the content as string, whereas the value for type = 'code' is another dictionary with two keys,
|
||||
statements and output. The statements key contains all lines in between ```py\n``` (including) until ```\n```, while output contains all lines after
|
||||
```.output py\n```.
|
||||
:type cell_contents: List[Dict]
|
||||
|
||||
:param read_only (optional): If True then only print outputs are included in converted
|
||||
cells. Default False
|
||||
:type read_only (optional): bool
|
||||
|
||||
:returns A Jupyter notebook containing all cells from input parameter `cell_contents`.
|
||||
Each converted cell has metadata attribute collapsed set to true if it's code-cell otherwise None if it's markdow-cell.
|
||||
"""
|
||||
cells = []
|
||||
for stuff in cell_contents:
|
||||
if stuff["type"] == "markdown":
|
||||
|
@ -269,6 +309,9 @@ def convert_to_cells(cell_contents, read_only):
|
|||
|
||||
|
||||
def convert_to_notebook(pre_examples_content, parsed_json, post_examples_content):
|
||||
"""
|
||||
Convert a JSON file containing the examples to a Jupyter Notebook.
|
||||
"""
|
||||
result = {
|
||||
"cells": [],
|
||||
"metadata": {},
|
||||
|
@ -296,7 +339,7 @@ def convert_to_notebook(pre_examples_content, parsed_json, post_examples_content
|
|||
|
||||
#pprint.pprint(result, indent=2)
|
||||
with open(notebook_path, "w") as f:
|
||||
json.dump(result, f)
|
||||
json.dump(result, f, indent=2)
|
||||
|
||||
|
||||
with open(fpath, 'r+', encoding="utf-8") as f:
|
||||
|
|
19
irrelevant/notebook_instructions.md
vendored
19
irrelevant/notebook_instructions.md
vendored
|
@ -5,22 +5,3 @@
|
|||
- Reorder the examples, so that the ones that work are upfront.
|
||||
- Run the `notebook_generator.py`, it will generate a notebook named `wtf.ipynb`
|
||||
- Revert the README.md changes (optional)
|
||||
|
||||
|
||||
# Hosted notebook instructions
|
||||
|
||||
This is just an experimental attempt of browsing wtfpython through jupyter notebooks. Some examples are read-only because,
|
||||
- they either require a version of Python that's not supported in the hosted runtime.
|
||||
- or they can't be reproduced in the notebook envrinonment.
|
||||
|
||||
The expected outputs are already present in collapsed cells following the code cells. The Google colab provides Python2 (2.7) and Python3 (3.6, default) runtimes. You can switch among these for Python2 specific examples. For examples specific to other minor versions, you can simply refer to collapsed outputs (it's not possible to control the minor version in hosted notebooks as of now). You can check the active version using
|
||||
|
||||
```py
|
||||
>>> import sys
|
||||
>>> sys.version
|
||||
# Prints out Python version here.
|
||||
```
|
||||
|
||||
That being said, most of tbe examples do work as expected. If you face any trouble, feel free to consult the original content on wtfpython and create an issue in the repo. Have fun!
|
||||
|
||||
|
||||
|
|
2
irrelevant/obsolete/add_categories
vendored
2
irrelevant/obsolete/add_categories
vendored
|
@ -139,7 +139,7 @@ f*
|
|||
Half triple-quoted strings
|
||||
f
|
||||
|
||||
Implicity key type conversion
|
||||
Implicit key type conversion
|
||||
f*
|
||||
|
||||
Stubborn `del` operator
|
||||
|
|
13479
irrelevant/wtf.ipynb
vendored
13479
irrelevant/wtf.ipynb
vendored
File diff suppressed because one or more lines are too long
63
translations/ru-russian/CONTRIBUTING.md
vendored
Normal file
63
translations/ru-russian/CONTRIBUTING.md
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
Приветствуются все виды изменений. Не стесняйтесь предлагать броские и смешные названия для существующих примеров. Цель - сделать эту коллекцию как можно более интересной для чтения. Вот несколько способов, с помощью которых вы можете внести свой вклад,
|
||||
|
||||
- Если вы заинтересованы в переводе проекта на другой язык (некоторые люди уже делали это в прошлом), пожалуйста, не стесняйтесь открыть тему и дайте мне знать, если вам нужна какая-либо помощь.
|
||||
- Если изменения, которые вы предлагаете, значительны, то создание issue перед внесением изменений будет оценено по достоинству. Если вы хотите поработать над issue (это очень рекомендуется), выразите свою заинтересованность и вы будете назначены исполнителем.
|
||||
- Если вы добавляете новый пример, настоятельно рекомендуется создать issue, чтобы обсудить ее перед отправкой изменений. Для добавления нового примера вы можете использовать следующий шаблон:
|
||||
|
||||
<pre>
|
||||
### ▶ Какое-то причудливое название. *
|
||||
* в конце названия означает, что пример был добавлен недавно.
|
||||
|
||||
```py
|
||||
# Подготовка кода.
|
||||
# Подготовка к волшебству...
|
||||
```
|
||||
|
||||
**Вывод (версия Python):**
|
||||
```py
|
||||
>>> triggering_statement
|
||||
Вероятно, неожиданный вывод
|
||||
|
||||
```
|
||||
(Необязательно): Одна строка, описывающая неожиданный вывод.
|
||||
|
||||
#### 💡 Объяснение:
|
||||
* Краткое объяснение того, что происходит и почему это происходит.
|
||||
```py
|
||||
Подготовка примеров для пояснения (при необходимости)
|
||||
```
|
||||
|
||||
**Вывод:**
|
||||
```py
|
||||
>>> trigger # пример, облегчающий понимание магии
|
||||
# обоснованный вывод
|
||||
```
|
||||
</pre>
|
||||
|
||||
Несколько моментов, которые стоит учитывать при написании примера,
|
||||
|
||||
- Если вы решили отправить новый пример без создания issue и обсуждения, пожалуйста, проверьте проект, чтобы убедиться, что в нем уже нет похожих примеров.
|
||||
- Старайтесь быть последовательными в именах и значениях, которые вы используете для переменных. Например, большинство имен переменных в проекте имеют вид `some_string`, `some_list`, `some_dict` и т.д. Вы увидите много `x` для однобуквенных имен переменных, и `"wtf"` в качестве значений для строк. В проекте нет строгой схемы, как таковой, но вы можете взглянуть на другие примеры, чтобы понять суть.
|
||||
- Старайтесь быть как можно более креативными, чтобы добавить элемент "сюрприза" во время подготовки примеров. Иногда это может означать написание фрагмента, который здравомыслящий программист никогда бы не написал.
|
||||
- Также не стесняйтесь добавлять свое имя в список [контрибьюторов](/CONTRIBUTORS.md).
|
||||
|
||||
**Некоторые часто задаваемые вопросы**
|
||||
|
||||
Что это такое после каждого заголовка сниппета (###) в README: <!-- ID примера: 30f1d3fc-e267-4b30-84ef-4d9e7091ac1a --->? Нужно ли его добавлять вручную или можно игнорировать при создании новых сниппетов?
|
||||
|
||||
Это случайный UUID, он используется для идентификации примеров в нескольких переводах проекта. Как контрибьютор, вы не должны беспокоиться о том, как он используется, вы просто должны добавлять новый случайный UUID к новым примерам в этом формате.
|
||||
|
||||
Куда следует добавлять новые сниппеты? В начало/в конец раздела?
|
||||
|
||||
При определении порядка учитывается множество факторов (зависимость от других примеров, уровень сложности, категория и т.д.). Я бы предложил просто добавить новый пример в конец раздела, который вы считаете более подходящим (или просто добавить его в раздел "Разное"). О его порядке можно будет позаботиться в будущих редакциях.
|
||||
|
||||
В чем разница между разделами (первые два очень похожи)?
|
||||
|
||||
Раздел "Напрягите мозг" содержит более надуманные примеры, с которыми вы не столкнетесь в реальной жизни, в то время как раздел "Скользкие склоны" содержит примеры, с которыми можно чаще сталкиваться при программировании.
|
||||
|
||||
Перед оглавлением написано, что для его создания использовался markdown-toc -i README.md --maxdepth 3. Пакет pip markdown-toc не содержит ни флагов -i, ни --maxdepth. Какой пакет имеется в виду, или какая версия этого пакета?
|
||||
Должна ли новая запись в оглавлении для фрагмента быть создана с помощью вышеуказанной команды или вручную (в случае, если вышеуказанная команда делает больше, чем просто добавляет запись)?
|
||||
|
||||
Мы используем пакет [markdown-toc](https://www.npmjs.com/package/markdown-toc) npm для создания ToC (содержание). Однако у него есть некоторые проблемы со специальными символами (не уверен, что они уже исправлены). Чаще всего я просто вставляю ссылку toc вручную в нужное место. Инструмент удобен, когда мне нужно сделать большую перестановку, в остальных случаях просто обновлять toc вручную удобнее.
|
||||
|
||||
Если у вас есть вопросы, не стесняйтесь спрашивать в [issue](https://github.com/satwikkansal/wtfpython/issues/269) (спасибо [@LiquidFun](https://github.com/LiquidFun) за ее создание).
|
42
translations/ru-russian/CONTRIBUTORS.md
vendored
Normal file
42
translations/ru-russian/CONTRIBUTORS.md
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
Ниже перечислены (без определенного порядка) замечательные люди, которые внесли вклад в развитие wtfpython.
|
||||
|
||||
| Автор | Github | Issues |
|
||||
|-------------|--------|--------|
|
||||
| Lucas-C | [Lucas-C](https://github.com/Lucas-C) | [#36](https://github.com/satwikkansal/wtfpython/issues/36) |
|
||||
| MittalAshok | [MittalAshok](https://github.com/MittalAshok) | [#23](https://github.com/satwikkansal/wtfpython/issues/23) |
|
||||
| asottile | [asottile](https://github.com/asottile) | [#40](https://github.com/satwikkansal/wtfpython/issues/40) |
|
||||
| MostAwesomeDude | [MostAwesomeDude](https://github.com/MostAwesomeDude) | [#1](https://github.com/satwikkansal/wtfpython/issues/1) |
|
||||
| tukkek | [tukkek](https://github.com/tukkek) | [#11](https://github.com/satwikkansal/wtfpython/issues/11), [#26](https://github.com/satwikkansal/wtfpython/issues/26) |
|
||||
| PiaFraus | [PiaFraus](https://github.com/PiaFraus) | [#9](https://github.com/satwikkansal/wtfpython/issues/9) |
|
||||
| chris-rands | [chris-rands](https://github.com/chris-rands) | [#32](https://github.com/satwikkansal/wtfpython/issues/32) |
|
||||
| sohaibfarooqi | [sohaibfarooqi](https://github.com/sohaibfarooqi) | [#63](https://github.com/satwikkansal/wtfpython/issues/63) |
|
||||
| ipid | [ipid](https://github.com/ipid) | [#145](https://github.com/satwikkansal/wtfpython/issues/145) |
|
||||
| roshnet | [roshnet](https://github.com/roshnet) | [#140](https://github.com/satwikkansal/wtfpython/issues/140) |
|
||||
| daidai21 | [daidai21](https://github.com/daidai21) | [#137](https://github.com/satwikkansal/wtfpython/issues/137) |
|
||||
| scidam | [scidam](https://github.com/scidam) | [#136](https://github.com/satwikkansal/wtfpython/issues/136) |
|
||||
| pmjpawelec | [pmjpawelec](https://github.com/pmjpawelec) | [#121](https://github.com/satwikkansal/wtfpython/issues/121) |
|
||||
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [#112](https://github.com/satwikkansal/wtfpython/issues/112) |
|
||||
| mishaturnbull | [mishaturnbull](https://github.com/mishaturnbull) | [#108](https://github.com/satwikkansal/wtfpython/issues/108) |
|
||||
| MuseBoy | [MuseBoy](https://github.com/MuseBoy) | [#101](https://github.com/satwikkansal/wtfpython/issues/101) |
|
||||
| Ghost account | N/A | [#96](https://github.com/satwikkansal/wtfpython/issues/96) |
|
||||
| koddo | [koddo](https://github.com/koddo) | [#80](https://github.com/satwikkansal/wtfpython/issues/80), [#73](https://github.com/satwikkansal/wtfpython/issues/73) |
|
||||
| jab | [jab](https://github.com/jab) | [#77](https://github.com/satwikkansal/wtfpython/issues/77) |
|
||||
| Jongy | [Jongy](https://github.com/Jongy) | [#208](https://github.com/satwikkansal/wtfpython/issues/208), [#210](https://github.com/satwikkansal/wtfpython/issues/210), [#233](https://github.com/satwikkansal/wtfpython/issues/233) |
|
||||
| Diptangsu Goswami | [diptangsu](https://github.com/diptangsu) | [#193](https://github.com/satwikkansal/wtfpython/issues/193) |
|
||||
| Charles | [charles-l](https://github.com/charles-l) | [#245](https://github.com/satwikkansal/wtfpython/issues/245) |
|
||||
| LiquidFun | [LiquidFun](https://github.com/LiquidFun) | [#267](https://github.com/satwikkansal/wtfpython/issues/267) |
|
||||
|
||||
---
|
||||
|
||||
**Переводчики**
|
||||
|
||||
| Переводчик | Github | Язык |
|
||||
|-------------|--------|--------|
|
||||
| leisurelicht | [leisurelicht](https://github.com/leisurelicht) | [Chinese](https://github.com/leisurelicht/wtfpython-cn) |
|
||||
| vuduclyunitn | [vuduclyunitn](https://github.com/vuduclyunitn) | [Vietnamese](https://github.com/vuduclyunitn/wtfptyhon-vi) |
|
||||
| José De Freitas | [JoseDeFreitas](https://github.com/JoseDeFreitas) | [Spanish](https://github.com/JoseDeFreitas/wtfpython-es) |
|
||||
| Vadim Nifadev | [nifadyev](https://github.com/nifadyev) | [Russian](https://github.com/satwikkansal/wtfpython/tree/master/translations/ru-russian) |
|
||||
|
||||
Спасибо всем за ваше время и за то, что делаете wtfpython еще более потрясающим! :smile:
|
||||
|
||||
PS: Этот список обновляется после каждого крупного релиза, если я забыл добавить сюда ваш вклад, пожалуйста, не стесняйтесь сделать Pull request.
|
3948
translations/ru-russian/README.md
vendored
Normal file
3948
translations/ru-russian/README.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
translations/ru-russian/code-of-conduct.md
vendored
Normal file
70
translations/ru-russian/code-of-conduct.md
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
# Кодекс Поведения участника
|
||||
|
||||
## Наши обязательства
|
||||
|
||||
Мы, как участники, авторы и лидеры обязуемся сделать участие в сообществе
|
||||
свободным от притеснений для всех, независимо от возраста, телосложения,
|
||||
видимых или невидимых ограничений способности, этнической принадлежности,
|
||||
половых признаков, гендерной идентичности и выражения, уровня опыта,
|
||||
образования, социально-экономического статуса, национальности, внешности,
|
||||
расы, религии, или сексуальной идентичности и ориентации.
|
||||
|
||||
Мы обещаем действовать и взаимодействовать таким образом, чтобы вносить вклад в открытое,
|
||||
дружелюбное, многообразное, инклюзивное и здоровое сообщество.
|
||||
|
||||
## Наши стандарты
|
||||
|
||||
Примеры поведения, создающие условия для благоприятных взаимоотношений включают в себя:
|
||||
|
||||
* Проявление доброты и эмпатии к другим участникам проекта
|
||||
* Уважение к чужой точке зрения и опыту
|
||||
* Конструктивная критика и принятие конструктивной критики
|
||||
* Принятие ответственности, принесение извинений тем, кто пострадал от наших ошибок
|
||||
и извлечение уроков из опыта
|
||||
* Ориентирование на то, что лучше подходит для сообщества, а не только для нас лично
|
||||
|
||||
Примеры неприемлемого поведения участников включают в себя:
|
||||
|
||||
* Использование выражений или изображений сексуального характера и нежелательное сексуальное внимание или домогательство в любой форме
|
||||
* Троллинг, оскорбительные или уничижительные комментарии, переход на личности или затрагивание политических убеждений
|
||||
* Публичное или приватное домогательство
|
||||
* Публикация личной информации других лиц, например, физического или электронного адреса, без явного разрешения
|
||||
* Иное поведение, которое обоснованно считать неуместным в профессиональной обстановке
|
||||
|
||||
## Обязанности
|
||||
|
||||
Лидеры сообщества отвечают за разъяснение и применение наших стандартов приемлемого
|
||||
поведения и будут предпринимать соответствующие и честные меры по исправлению положения
|
||||
в ответ на любое поведение, которое они сочтут неприемлемым, угрожающим, оскорбительным или вредным.
|
||||
|
||||
Лидеры сообщества обладают правом и обязанностью удалять, редактировать или отклонять
|
||||
комментарии, коммиты, код, изменения в вики, вопросы и другой вклад, который не совпадает
|
||||
с Кодексом Поведения, и предоставят причины принятого решения, когда сочтут нужным.
|
||||
|
||||
## Область применения
|
||||
|
||||
Данный Кодекс Поведения применим во всех публичных физических и цифровых пространства сообщества,
|
||||
а также когда человек официально представляет сообщество в публичных местах.
|
||||
Примеры представления проекта или сообщества включают использование официальной электронной почты,
|
||||
публикации в официальном аккаунте в социальных сетях,
|
||||
или упоминания как представителя в онлайн или офлайн мероприятии.
|
||||
|
||||
## Приведение в исполнение
|
||||
|
||||
О случаях домогательства, а так же оскорбительного или иного другого неприемлемого
|
||||
поведения можно сообщить ответственным лидерам сообщества с помощью email.
|
||||
Все жалобы будут рассмотрены и расследованы оперативно и беспристрастно.
|
||||
|
||||
Все лидеры сообщества обязаны уважать неприкосновенность частной жизни и личную
|
||||
неприкосновенность автора сообщения.
|
||||
|
||||
## Атрибуция
|
||||
|
||||
Данный Кодекс Поведения основан на [Кодекс Поведения участника][homepage],
|
||||
версии 2.0, доступной по адресу
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Принципы Воздействия в Сообществе были вдохновлены [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
2
wtfpython-pypi/content.md
vendored
2
wtfpython-pypi/content.md
vendored
|
@ -1732,7 +1732,7 @@ UnboundLocalError: local variable 'a' referenced before assignment
|
|||
|
||||
#### 💡 Explanation:
|
||||
* When you make an assignment to a variable in scope, it becomes local to that scope. So `a` becomes local to the scope of `another_func`, but it has not been initialized previously in the same scope which throws an error.
|
||||
* Read [this](http://sebastianraschka.com/Articles/2014_python_scope_and_namespaces.html) short but an awesome guide to learn more about how namespaces and scope resolution works in Python.
|
||||
* Read [this](https://sebastianraschka.com/Articles/2014_python_scope_and_namespaces.html) short but an awesome guide to learn more about how namespaces and scope resolution works in Python.
|
||||
* To modify the outer scope variable `a` in `another_func`, use `global` keyword.
|
||||
```py
|
||||
def another_func()
|
||||
|
|
|
@ -13,6 +13,10 @@ file_path = join(dirname(dirname(realpath(__file__))), "content.md")
|
|||
|
||||
|
||||
def fetch_updated_doc():
|
||||
"""
|
||||
Fetch the latest version of the file at `url` and save it to `file_path`.
|
||||
If anything goes wrong, do nothing.
|
||||
"""
|
||||
try:
|
||||
print("Fetching the latest version...")
|
||||
urlretrieve(url, file_path)
|
||||
|
|
Loading…
Reference in New Issue
Block a user