From 1924d58159ce340f96dd1443890f8cc99ad81976 Mon Sep 17 00:00:00 2001 From: Boris Verkhovskiy Date: Fri, 26 Apr 2024 01:48:54 -0700 Subject: [PATCH] [python/*] proofread en and ru and all links --- ar-ar/python-ar.html.markdown | 5 +- de-de/python-de.html.markdown | 3 +- el-gr/python-gr.html.markdown | 6 +- es-es/python-es.html.markdown | 3 +- fr-fr/python-fr.html.markdown | 3 +- it-it/python-it.html.markdown | 6 +- ja-jp/python-jp.html.markdown | 6 +- pt-br/python-pt.html.markdown | 6 +- python.html.markdown | 177 +++++++++++++++++----------------- ru-ru/python-ru.html.markdown | 53 +++++----- tr-tr/python-tr.html.markdown | 6 +- vi-vn/python-vi.html.markdown | 6 +- zh-cn/python-cn.html.markdown | 12 +-- 13 files changed, 131 insertions(+), 161 deletions(-) diff --git a/ar-ar/python-ar.html.markdown b/ar-ar/python-ar.html.markdown index e6a487b8..870d17a9 100644 --- a/ar-ar/python-ar.html.markdown +++ b/ar-ar/python-ar.html.markdown @@ -1003,14 +1003,11 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( ### مجانا عبر الانترنت * [أتمتتة المهمات المُملة عبر بايثون](https://automatetheboringstuff.com) -* [أفكار لمشروعات بلغة البايثون](http://pythonpracticeprojects.com) * [التوثيقات الرسمية](http://docs.python.org/3/) * [دليل المُسافر لبايثون](http://docs.python-guide.org/en/latest/) * [دورة بايثون](http://www.python-course.eu/index.php) * [أولى الخطوات مع بايثون](https://realpython.com/learn/python-first-steps/) * [قائمة مُختارة من إطارات عمل بايثون الرائعة, المكتبات والبرمجيات](https://github.com/vinta/awesome-python) -* [ثلاثون خاصية وخدعة للغة البايثون ربما لم تعرف بها](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [الدليل الرسمي لنمط البايثون](https://www.python.org/dev/peps/pep-0008/) +* [الدليل الرسمي لنمط البايثون](https://peps.python.org/pep-0008/) * [بايثون 3 دوائر علوم الحاسب](http://cscircles.cemc.uwaterloo.ca/) * [غُص في بايثون 3](http://www.diveintopython3.net/index.html) -* [دورة سريعة في البايثون للعلماء](http://nbviewer.jupyter.org/gist/anonymous/5924718) diff --git a/de-de/python-de.html.markdown b/de-de/python-de.html.markdown index f8ea5cb5..92222f6d 100644 --- a/de-de/python-de.html.markdown +++ b/de-de/python-de.html.markdown @@ -631,8 +631,7 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [Dive Into Python](http://www.diveintopython.net/) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) -* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) diff --git a/el-gr/python-gr.html.markdown b/el-gr/python-gr.html.markdown index 94a0a64c..aecd88f4 100644 --- a/el-gr/python-gr.html.markdown +++ b/el-gr/python-gr.html.markdown @@ -1015,12 +1015,10 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/) * [Dive Into Python 3](http://www.diveintopython3.net/index.html) -* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718) diff --git a/es-es/python-es.html.markdown b/es-es/python-es.html.markdown index 2cb48144..cc53f944 100644 --- a/es-es/python-es.html.markdown +++ b/es-es/python-es.html.markdown @@ -562,9 +562,8 @@ print(decir(decir_por_favor=True)) # ¿Puedes comprarme una cerveza? ¡Por favo * [Dive Into Python](http://www.diveintopython.net/) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Module of the Week](http://pymotw.com/3/) -* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) ### Encuadernados diff --git a/fr-fr/python-fr.html.markdown b/fr-fr/python-fr.html.markdown index 2bab900b..15abab4d 100644 --- a/fr-fr/python-fr.html.markdown +++ b/fr-fr/python-fr.html.markdown @@ -713,8 +713,7 @@ print(say(say_please=True)) # affiche Can you buy me a beer? Please! I am poor * [Dive Into Python](http://www.diveintopython.net/) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) -* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) diff --git a/it-it/python-it.html.markdown b/it-it/python-it.html.markdown index 85632a44..31ef75ea 100644 --- a/it-it/python-it.html.markdown +++ b/it-it/python-it.html.markdown @@ -1002,12 +1002,10 @@ print(say(say_please=True)) # Puoi comprarmi una birra? Per favore! Sono povero * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/) * [Dive Into Python 3](http://www.diveintopython3.net/index.html) -* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718) diff --git a/ja-jp/python-jp.html.markdown b/ja-jp/python-jp.html.markdown index b492bd8b..fa272ba6 100644 --- a/ja-jp/python-jp.html.markdown +++ b/ja-jp/python-jp.html.markdown @@ -996,12 +996,10 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/) * [Dive Into Python 3](http://www.diveintopython3.net/index.html) -* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718) diff --git a/pt-br/python-pt.html.markdown b/pt-br/python-pt.html.markdown index 46eb524f..db14923c 100644 --- a/pt-br/python-pt.html.markdown +++ b/pt-br/python-pt.html.markdown @@ -726,13 +726,11 @@ print(say(say_please=True)) # Você me paga uma cerveja? Por favor! Eu sou pobre * [Dive Into Python](http://www.diveintopython.net/) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) -* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) ### Dead Tree diff --git a/python.html.markdown b/python.html.markdown index f9a36da1..a9b5f92c 100644 --- a/python.html.markdown +++ b/python.html.markdown @@ -42,7 +42,7 @@ syntactic clarity. It's basically executable pseudocode. # Integer division rounds down for both positive and negative numbers. 5 // 3 # => 1 -5 // 3 # => -2 -5.0 // 3.0 # => 1.0 # works on floats too +5.0 // 3.0 # => 1.0 # works on floats too -5.0 // 3.0 # => -2.0 # The result of division is always a float @@ -74,36 +74,36 @@ True and False # => False False or True # => True # True and False are actually 1 and 0 but with different keywords -True + True # => 2 -True * 8 # => 8 -False - 5 # => -5 +True + True # => 2 +True * 8 # => 8 +False - 5 # => -5 # Comparison operators look at the numerical value of True and False -0 == False # => True -2 > True # => True -2 == True # => False --5 != False # => True +0 == False # => True +2 > True # => True +2 == True # => False +-5 != False # => True # None, 0, and empty strings/lists/dicts/tuples/sets all evaluate to False. # All other values are True -bool(0) # => False -bool("") # => False -bool([]) # => False -bool({}) # => False -bool(()) # => False -bool(set()) # => False -bool(4) # => True -bool(-6) # => True +bool(0) # => False +bool("") # => False +bool([]) # => False +bool({}) # => False +bool(()) # => False +bool(set()) # => False +bool(4) # => True +bool(-6) # => True # Using boolean logical operators on ints casts them to booleans for evaluation, # but their non-cast value is returned. Don't mix up with bool(ints) and bitwise # and/or (&,|) -bool(0) # => False -bool(2) # => True -0 and 2 # => 0 -bool(-5) # => True -bool(2) # => True --5 or 0 # => -5 +bool(0) # => False +bool(2) # => True +0 and 2 # => 0 +bool(-5) # => True +bool(2) # => True +-5 or 0 # => -5 # Equality is == 1 == 1 # => True @@ -153,9 +153,9 @@ len("This is a string") # => 16 # Since Python 3.6, you can use f-strings or formatted string literals. name = "Reiko" -f"She said her name is {name}." # => "She said her name is Reiko" +f"She said her name is {name}." # => "She said her name is Reiko" # Any valid Python expression inside these braces is returned to the string. -f"{name} is {len(name)} characters long." # => "Reiko is 5 characters long." +f"{name} is {len(name)} characters long." # => "Reiko is 5 characters long." # None is an object None # => None @@ -177,7 +177,7 @@ print("I'm Python. Nice to meet you!") # => I'm Python. Nice to meet you! print("Hello, World", end="!") # => Hello, World! # Simple way to get input data from console -input_string_var = input("Enter some data: ") # Returns the data as a string +input_string_var = input("Enter some data: ") # Returns the data as a string # There are no declarations, only assignments. # Convention in naming variables is snake_case style @@ -340,9 +340,8 @@ filled_dict["four"] = 4 # another way to add to dict del filled_dict["one"] # Removes the key "one" from filled dict # From Python 3.5 you can also use the additional unpacking options -{'a': 1, **{'b': 2}} # => {'a': 1, 'b': 2} -{'a': 1, **{'a': 2}} # => {'a': 2} - +{"a": 1, **{"b": 2}} # => {'a': 1, 'b': 2} +{"a": 1, **{"a": 2}} # => {'a': 2} # Sets store ... well sets @@ -374,10 +373,10 @@ filled_set | other_set # => {1, 2, 3, 4, 5, 6} {1, 2, 3, 4} ^ {2, 3, 5} # => {1, 4, 5} # Check if set on the left is a superset of set on the right -{1, 2} >= {1, 2, 3} # => False +{1, 2} >= {1, 2, 3} # => False # Check if set on the left is a subset of set on the right -{1, 2} <= {1, 2, 3} # => True +{1, 2} <= {1, 2, 3} # => True # Check for existence in a set with in 2 in filled_set # => True @@ -501,15 +500,15 @@ with open("myfile1.txt", "w") as file: import json with open("myfile2.txt", "w") as file: - file.write(json.dumps(contents)) # writes an object to a file + file.write(json.dumps(contents)) # writes an object to a file # Reading from a file -with open('myfile1.txt', "r") as file: +with open("myfile1.txt") as file: contents = file.read() # reads a string from a file print(contents) # print: {"aa": 12, "bb": 21} -with open('myfile2.txt', "r") as file: +with open("myfile2.txt", "r") as file: contents = json.load(file) # reads a json object from a file print(contents) # print: {"aa": 12, "bb": 21} @@ -662,9 +661,9 @@ def create_avg(): return total/count return avg avg = create_avg() -avg(3) # => 3.0 -avg(5) # (3+5)/2 => 4.0 -avg(7) # (8+7)/3 => 5.0 +avg(3) # => 3.0 +avg(5) # (3+5)/2 => 4.0 +avg(7) # (8+7)/3 => 5.0 # There are also anonymous functions (lambda x: x > 2)(3) # => True @@ -682,7 +681,7 @@ list(filter(lambda x: x > 5, [3, 4, 5, 6, 7])) # => [6, 7] [x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] # You can construct set and dict comprehensions as well. -{x for x in 'abcddeef' if x not in 'abc'} # => {'d', 'e', 'f'} +{x for x in "abcddeef" if x not in "abc"} # => {'d', 'e', 'f'} {x: x**2 for x in range(5)} # => {0: 0, 1: 1, 2: 4, 3: 9, 4: 16} @@ -744,7 +743,7 @@ class Human: self.name = name # Initialize property - self._age = 0 # the leading underscore indicates the "age" property is + self._age = 0 # the leading underscore indicates the "age" property is # intended to be used internally # do not rely on this to be enforced: it's a hint to other devs @@ -754,7 +753,7 @@ class Human: # Another instance method def sing(self): - return 'yo... yo... microphone check... one two... one two...' + return "yo... yo... microphone check... one two... one two..." # A class method is shared among all instances # They are called with the calling class as the first argument @@ -788,7 +787,7 @@ class Human: # When a Python interpreter reads a source file it executes all its code. # This __name__ check makes sure this code block is only executed when this # module is the main program. -if __name__ == '__main__': +if __name__ == "__main__": # Instantiate a class i = Human(name="Ian") i.say("hi") # "Ian: hi" @@ -849,7 +848,7 @@ class Superhero(Human): # pass # Child classes can override their parents' attributes - species = 'Superhuman' + species = "Superhuman" # Children automatically inherit their parent class's constructor including # its arguments, but can also define additional arguments or definitions @@ -872,7 +871,7 @@ class Superhero(Human): # override the sing method def sing(self): - return 'Dun, dun, DUN!' + return "Dun, dun, DUN!" # add an additional instance method def boast(self): @@ -880,14 +879,14 @@ class Superhero(Human): print("I wield the power of {pow}!".format(pow=power)) -if __name__ == '__main__': +if __name__ == "__main__": sup = Superhero(name="Tick") # Instance type checks if isinstance(sup, Human): - print('I am human') + print("I am human") if type(sup) is Superhero: - print('I am a superhero') + print("I am a superhero") # Get the "Method Resolution Order" used by both getattr() and super() # (the order in which classes are searched for an attribute or method) @@ -902,7 +901,7 @@ if __name__ == '__main__': print(sup.sing()) # => Dun, dun, DUN! # Calls method from Human - sup.say('Spoon') # => Tick: Spoon + sup.say("Spoon") # => Tick: Spoon # Call method that exists only in Superhero sup.boast() # => I wield the power of super strength! @@ -913,33 +912,35 @@ if __name__ == '__main__': print(sup.age) # => 31 # Attribute that only exists within Superhero - print('Am I Oscar eligible? ' + str(sup.movie)) + print("Am I Oscar eligible? " + str(sup.movie)) #################################################### ## 6.2 Multiple Inheritance #################################################### + # Another class definition # bat.py class Bat: - species = 'Baty' + species = "Baty" def __init__(self, can_fly=True): self.fly = can_fly # This class also has a say method def say(self, msg): - msg = '... ... ...' + msg = "... ... ..." return msg # And its own method as well def sonar(self): - return '))) ... (((' + return "))) ... (((" -if __name__ == '__main__': + +if __name__ == "__main__": b = Bat() - print(b.say('hello')) + print(b.say("hello")) print(b.fly) @@ -959,44 +960,43 @@ class Batman(Superhero, Bat): # So instead we explicitly call __init__ for all ancestors. # The use of *args and **kwargs allows for a clean way to pass # arguments, with each parent "peeling a layer of the onion". - Superhero.__init__(self, 'anonymous', movie=True, - superpowers=['Wealthy'], *args, **kwargs) + Superhero.__init__(self, "anonymous", movie=True, + superpowers=["Wealthy"], *args, **kwargs) Bat.__init__(self, *args, can_fly=False, **kwargs) # override the value for the name attribute - self.name = 'Sad Affleck' + self.name = "Sad Affleck" def sing(self): - return 'nan nan nan nan nan batman!' + return "nan nan nan nan nan batman!" -if __name__ == '__main__': +if __name__ == "__main__": sup = Batman() # The Method Resolution Order - print(Batman.__mro__) # => (, - # => , - # => , - # => , ) + print(Batman.__mro__) # => (, + # => , + # => , + # => , ) # Calls parent method but uses its own class attribute - print(sup.get_species()) # => Superhuman + print(sup.get_species()) # => Superhuman # Calls overridden method - print(sup.sing()) # => nan nan nan nan nan batman! + print(sup.sing()) # => nan nan nan nan nan batman! # Calls method from Human, because inheritance order matters - sup.say('I agree') # => Sad Affleck: I agree + sup.say("I agree") # => Sad Affleck: I agree # Call method that exists only in 2nd ancestor - print(sup.sonar()) # => ))) ... ((( + print(sup.sonar()) # => ))) ... ((( # Inherited class attribute sup.age = 100 - print(sup.age) # => 100 + print(sup.age) # => 100 # Inherited attribute from 2nd ancestor whose default value was overridden. - print('Can I fly? ' + str(sup.fly)) # => Can I fly? False - + print("Can I fly? " + str(sup.fly)) # => Can I fly? False #################################################### @@ -1052,15 +1052,15 @@ def my_function(x,y): # def my_function(x,y): # When function definitions are long, it can be hard to parse the non-decorated # assignment at the end of the definition. -my_function(1,2) # => "Entering function my_function" - # => "3" - # => "Exiting function my_function" +my_function(1,2) # => "Entering function my_function" + # => "3" + # => "Exiting function my_function" # But there's a problem. # What happens if we try to get some information about my_function? -print(my_function.__name__) # => 'wrapper' -print(my_function.__code__.co_argcount) # => 0. The argcount is 0 because both arguments in wrapper()'s signature are optional. +print(my_function.__name__) # => 'wrapper' +print(my_function.__code__.co_argcount) # => 0. The argcount is 0 because both arguments in wrapper()'s signature are optional. # Because our decorator is equivalent to my_function = log_function(my_function) # we've replaced information about my_function with information from wrapper @@ -1070,8 +1070,8 @@ print(my_function.__code__.co_argcount) # => 0. The argcount is 0 because both a from functools import wraps def log_function(func): - @wraps(func) # this ensures docstring, function name, arguments list, etc. are all copied - # to the wrapped function - instead of being replaced with wrapper's info + @wraps(func) # this ensures docstring, function name, arguments list, etc. are all copied + # to the wrapped function - instead of being replaced with wrapper's info def wrapper(*args, **kwargs): print("Entering function", func.__name__) result = func(*args, **kwargs) @@ -1079,31 +1079,28 @@ def log_function(func): return result return wrapper -@log_function -def my_function(x,y): - return x+y - -my_function(1,2) # => "Entering function my_function" - # => "3" - # => "Exiting function my_function" +@log_function +def my_function(x,y): + return x+y -print(my_function.__name__) # => 'my_function' -print(my_function.__code__.co_argcount) # => 2 +my_function(1,2) # => "Entering function my_function" + # => "3" + # => "Exiting function my_function" + +print(my_function.__name__) # => 'my_function' +print(my_function.__code__.co_argcount) # => 2 ``` ### Free Online * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com) * [The Official Docs](https://docs.python.org/3/) -* [Hitchhiker's Guide to Python](https://docs.python-guide.org/en/latest/) +* [Hitchhiker's Guide to Python](https://docs.python-guide.org/) * [Python Course](https://www.python-course.eu) -* [Free Interactive Python Course](http://www.Kikodo.io) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](https://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](https://cscircles.cemc.uwaterloo.ca/) -* [Dive Into Python 3](https://www.diveintopython3.net/index.html) -* [A Crash Course in Python for Scientists](https://nbviewer.jupyter.org/gist/anonymous/5924718) +* [Dive Into Python 3](https://www.diveintopython3.net/) * [Python Tutorial for Intermediates](https://pythonbasics.org/) * [Build a Desktop App with Python](https://pythonpyqt.com/) diff --git a/ru-ru/python-ru.html.markdown b/ru-ru/python-ru.html.markdown index 40299c20..b1aeec2a 100644 --- a/ru-ru/python-ru.html.markdown +++ b/ru-ru/python-ru.html.markdown @@ -11,11 +11,11 @@ filename: learnpython-ru.py --- Язык Python был создан Гвидо ван Россумом в начале 90-х. Сейчас это один из -самых популярных языков. Я влюбился в Python за понятный и доходчивый синтаксис — это +самых популярных языков. Я влюбился в Python за понятный и доходчивый синтаксис — это почти что исполняемый псевдокод. Замечание: Эта статья относится только к Python 3. -Если вы хотите изучить Python 2.7, обратитесь к [другой статье](https://learnxinyminutes.com/docs/ru-ru/pythonlegacy-ru/). +Если вы хотите изучить Python 2.7, обратитесь к [другой статье](/docs/ru-ru/pythonlegacy-ru/). ```python # Однострочные комментарии начинаются с символа решётки. @@ -40,12 +40,12 @@ filename: learnpython-ru.py # Результат целочисленного деления округляется в меньшую сторону # как для положительных, так и для отрицательных чисел. -5 // 3 # => 1 --5 // 3 # => -2 -5.0 // 3.0 # => 1.0 # работает и для чисел с плавающей запятой --5.0 // 3.0 # => -2.0 +5 // 3 # => 1 +-5 // 3 # => -2 +5.0 // 3.0 # => 1.0 # работает и для чисел с плавающей запятой +-5.0 // 3.0 # => -2.0 -# # Результат деления возвращает число с плавающей запятой +# Результат деления возвращает число с плавающей запятой 10.0 / 3 # => 3.3333333333333335 # Остаток от деления @@ -125,7 +125,7 @@ b == a # => True, Объекты a и b равны "Это строка." 'Это тоже строка.' -# И строки тоже могут складываться! Хотя лучше не злоупотребляйте этим. +# И строки тоже могут складываться! "Привет " + "мир!" # => "Привет мир!" # Строки (но не переменные) могут быть объединены без использования '+' @@ -139,9 +139,9 @@ len("Это строка") # => 10 # Вы также можете форматировать, используя f-строки (в Python 3.6+) name = "Рейко" -f"Она сказала, что ее зовут {name}." # => "Она сказала, что ее зовут Рейко" +f"Она сказала, что ее зовут {name}." # => "Она сказала, что ее зовут Рейко" # Вы можете поместить любой оператор Python в фигурные скобки, и он будет выведен в строке. -f"{name} состоит из {len(name)} символов." # => "Рэйко состоит из 5 символов." +f"{name} состоит из {len(name)} символов." # => "Рэйко состоит из 5 символов." # None является объектом @@ -168,8 +168,8 @@ bool(()) # => False # В Python есть функция Print print("Я Python. Приятно познакомиться!") # => Я Python. Приятно познакомиться! -# По умолчанию функция, print() также выводит новую строку в конце. -# Используйте необязательный аргумент end, чтобы изменить последнюю строку. +# По умолчанию, функция print() также выводит новую строку в конце. +# Используйте необязательный аргумент end, чтобы изменить конец последней строки. print("Привет мир", end="!") # => Привет мир! # Простой способ получить входные данные из консоли @@ -245,7 +245,7 @@ li.index(4) # Выбрасывает ошибку ValueError поскольку li + other_li # => [1, 2, 3, 4, 5, 6] # Объединять списки можно методом extend() -li.extend(other_li) # Теперь li содержит [1, 2, 3, 4, 5, 6] +li.extend(other_li) # Теперь li содержит [1, 2, 3, 4, 5, 6] # Проверить элемент на наличие в списке можно оператором in 1 in li # => True @@ -273,7 +273,7 @@ tup[:2] # => (1, 2) # Вы можете распаковывать кортежи (или списки) в переменные a, b, c = (1, 2, 3) # a == 1, b == 2 и c == 3 # Вы также можете сделать расширенную распаковку -a, *b, c = (1, 2, 3, 4) # a теперь 1, b теперь [2, 3] и c теперь 4 +a, *b, c = (1, 2, 3, 4) # a теперь 1, b теперь [2, 3] и c теперь 4 # Кортежи создаются по умолчанию, если опущены скобки d, e, f = 4, 5, 6 # кортеж 4, 5, 6 распаковывается в переменные d, e и f # соответственно, d = 4, e = 5 и f = 6 @@ -496,19 +496,19 @@ with open("myfile.txt") as f: # Запись в файл contents = {"aa": 12, "bb": 21} with open("myfile1.txt", "w+") as file: - file.write(str(contents)) # Записывает строку в файл + file.write(str(contents)) # Записывает строку в файл with open("myfile2.txt", "w+") as file: - file.write(json.dumps(contents)) # Записывает объект в файл + file.write(json.dumps(contents)) # Записывает объект в файл # Чтение из файла -with open('myfile1.txt', "r+") as file: - contents = file.read() # Читает строку из файла -print(contents) # => '{"aa": 12, "bb": 21}' +with open("myfile1.txt", "r+") as file: + contents = file.read() # Читает строку из файла +print(contents) # => '{"aa": 12, "bb": 21}' -with open('myfile2.txt', "r") as file: - contents = json.load(file) # Читает объект json из файла -print(contents) # => {"aa": 12, "bb": 21} +with open("myfile2.txt", "r") as file: + contents = json.load(file) # Читает объект json из файла +print(contents) # => {"aa": 12, "bb": 21} # Python предоставляет фундаментальную абстракцию, @@ -969,7 +969,7 @@ if __name__ == '__main__': # Унаследованный атрибут от второго родителя, # значение по умолчанию которого было переопределено. - print('Могу ли я летать? ' + str(sup.fly)) # => Могу ли я летать? False + print('Могу ли я летать? ' + str(sup.fly)) # => Могу ли я летать? False #################################################### @@ -1034,16 +1034,13 @@ print(say(say_please=True)) # Вы не купите мне пива? Пожа ### Бесплатные онлайн-материалы * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com) -* [Ideas for Python Projects](http://pythonpracticeprojects.com) * [Официальная документация](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/) * [Dive Into Python 3](http://www.diveintopython3.net/index.html) -* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718) * [Python Tutorial for Intermediates](https://pythonbasics.org/) * [Build a Desktop App with Python](https://pythonpyqt.com/) diff --git a/tr-tr/python-tr.html.markdown b/tr-tr/python-tr.html.markdown index 235b5b36..bef337b0 100644 --- a/tr-tr/python-tr.html.markdown +++ b/tr-tr/python-tr.html.markdown @@ -622,13 +622,11 @@ print(soyle(lutfen_soyle=True)) # Ban soda alır mısın? Lutfen! Artık dayana * [Dive Into Python](http://www.diveintopython.net/) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) -* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/) ### Kitaplar diff --git a/vi-vn/python-vi.html.markdown b/vi-vn/python-vi.html.markdown index 3bc38a38..3e496c81 100644 --- a/vi-vn/python-vi.html.markdown +++ b/vi-vn/python-vi.html.markdown @@ -900,12 +900,10 @@ print(say(say_please=True)) # Mua bia cho tui nhé? Làm ơn! Tui rất nghèo * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com) * [Ideas for Python Projects](http://pythonpracticeprojects.com) * [The Official Docs](http://docs.python.org/3/) -* [Hitchhiker's Guide to Python](http://docs.python-guide.org/en/latest/) +* [Hitchhiker's Guide to Python](http://docs.python-guide.org/) * [Python Course](http://www.python-course.eu/index.php) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/) * [Dive Into Python 3](http://www.diveintopython3.net/index.html) -* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718) diff --git a/zh-cn/python-cn.html.markdown b/zh-cn/python-cn.html.markdown index 3d3b16d1..04691ff6 100644 --- a/zh-cn/python-cn.html.markdown +++ b/zh-cn/python-cn.html.markdown @@ -9,7 +9,6 @@ translators: - ["Maple", "https://github.com/mapleincode"] filename: learnpython-cn.py lang: zh-cn - --- Python 是由吉多·范罗苏姆(Guido Van Rossum)在 90 年代早期设计。 @@ -1015,8 +1014,6 @@ print(say()) # Can you buy me a beer? print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( ``` - - ## 想继续学吗? ### 在线免费材料(英文) @@ -1024,16 +1021,13 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :( * [Automate the Boring Stuff with Python](https://automatetheboringstuff.com/) * [Ideas for Python Projects](http://pythonpracticeprojects.com/) * [The Official Docs](https://docs.python.org/3/) -* [Hitchhiker’s Guide to Python](https://docs.python-guide.org/en/latest/) +* [Hitchhiker’s Guide to Python](https://docs.python-guide.org/) * [Python Course](https://www.python-course.eu/) -* [Free Interactive Python Course](http://www.kikodo.io/) * [First Steps With Python](https://realpython.com/learn/python-first-steps/) * [A curated list of awesome Python frameworks, libraries and software](https://github.com/vinta/awesome-python) -* [30 Python Language Features and Tricks You May Not Know About](https://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html) -* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/) +* [Official Style Guide for Python](https://peps.python.org/pep-0008/) * [Python 3 Computer Science Circles](https://cscircles.cemc.uwaterloo.ca/) -* [Dive Into Python 3](https://www.diveintopython3.net/index.html) -* [A Crash Course in Python for Scientists](https://nbviewer.jupyter.org/gist/anonymous/5924718) +* [Dive Into Python 3](https://www.diveintopython3.net/) * [Python Tutorial for Intermediates](https://pythonbasics.org/) * [Build a Desktop App with Python](https://pythonpyqt.com/)