mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-25 16:23:37 +03:00
[python/*] proofread en and ru and all links
This commit is contained in:
parent
cbb2eb4f00
commit
1924d58159
@ -1003,14 +1003,11 @@ print(say(say_please=True)) # Can you buy me a beer? Please! I am poor :(
|
|||||||
### مجانا عبر الانترنت
|
### مجانا عبر الانترنت
|
||||||
|
|
||||||
* [أتمتتة المهمات المُملة عبر بايثون](https://automatetheboringstuff.com)
|
* [أتمتتة المهمات المُملة عبر بايثون](https://automatetheboringstuff.com)
|
||||||
* [أفكار لمشروعات بلغة البايثون](http://pythonpracticeprojects.com)
|
|
||||||
* [التوثيقات الرسمية](http://docs.python.org/3/)
|
* [التوثيقات الرسمية](http://docs.python.org/3/)
|
||||||
* [دليل المُسافر لبايثون](http://docs.python-guide.org/en/latest/)
|
* [دليل المُسافر لبايثون](http://docs.python-guide.org/en/latest/)
|
||||||
* [دورة بايثون](http://www.python-course.eu/index.php)
|
* [دورة بايثون](http://www.python-course.eu/index.php)
|
||||||
* [أولى الخطوات مع بايثون](https://realpython.com/learn/python-first-steps/)
|
* [أولى الخطوات مع بايثون](https://realpython.com/learn/python-first-steps/)
|
||||||
* [قائمة مُختارة من إطارات عمل بايثون الرائعة, المكتبات والبرمجيات](https://github.com/vinta/awesome-python)
|
* [قائمة مُختارة من إطارات عمل بايثون الرائعة, المكتبات والبرمجيات](https://github.com/vinta/awesome-python)
|
||||||
* [ثلاثون خاصية وخدعة للغة البايثون ربما لم تعرف بها](http://sahandsaba.com/thirty-python-language-features-and-tricks-you-may-not-know.html)
|
* [الدليل الرسمي لنمط البايثون](https://peps.python.org/pep-0008/)
|
||||||
* [الدليل الرسمي لنمط البايثون](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [بايثون 3 دوائر علوم الحاسب](http://cscircles.cemc.uwaterloo.ca/)
|
* [بايثون 3 دوائر علوم الحاسب](http://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [غُص في بايثون 3](http://www.diveintopython3.net/index.html)
|
* [غُص في بايثون 3](http://www.diveintopython3.net/index.html)
|
||||||
* [دورة سريعة في البايثون للعلماء](http://nbviewer.jupyter.org/gist/anonymous/5924718)
|
|
||||||
|
@ -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/)
|
* [Dive Into Python](http://www.diveintopython.net/)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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/)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
|
|
||||||
* [Python Course](http://www.python-course.eu/index.php)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
||||||
|
|
||||||
|
@ -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)
|
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718)
|
|
||||||
|
@ -562,9 +562,8 @@ print(decir(decir_por_favor=True)) # ¿Puedes comprarme una cerveza? ¡Por favo
|
|||||||
* [Dive Into Python](http://www.diveintopython.net/)
|
* [Dive Into Python](http://www.diveintopython.net/)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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/)
|
* [Python Module of the Week](http://pymotw.com/3/)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
|
|
||||||
|
|
||||||
### Encuadernados
|
### Encuadernados
|
||||||
|
|
||||||
|
@ -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/)
|
* [Dive Into Python](http://www.diveintopython.net/)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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/)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
|
|
||||||
* [Python Course](http://www.python-course.eu/index.php)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
||||||
|
|
||||||
|
@ -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)
|
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718)
|
|
||||||
|
@ -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)
|
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718)
|
|
||||||
|
@ -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/)
|
* [Dive Into Python](http://www.diveintopython.net/)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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/)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
|
|
||||||
* [Python Course](http://www.python-course.eu/index.php)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
|
|
||||||
### Dead Tree
|
### Dead Tree
|
||||||
|
|
||||||
|
@ -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
|
del filled_dict["one"] # Removes the key "one" from filled dict
|
||||||
|
|
||||||
# From Python 3.5 you can also use the additional unpacking options
|
# From Python 3.5 you can also use the additional unpacking options
|
||||||
{'a': 1, **{'b': 2}} # => {'a': 1, 'b': 2}
|
{"a": 1, **{"b": 2}} # => {'a': 1, 'b': 2}
|
||||||
{'a': 1, **{'a': 2}} # => {'a': 2}
|
{"a": 1, **{"a": 2}} # => {'a': 2}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Sets store ... well sets
|
# Sets store ... well sets
|
||||||
@ -504,12 +503,12 @@ 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
|
# 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
|
contents = file.read() # reads a string from a file
|
||||||
print(contents)
|
print(contents)
|
||||||
# print: {"aa": 12, "bb": 21}
|
# 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
|
contents = json.load(file) # reads a json object from a file
|
||||||
print(contents)
|
print(contents)
|
||||||
# print: {"aa": 12, "bb": 21}
|
# print: {"aa": 12, "bb": 21}
|
||||||
@ -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]
|
[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7]
|
||||||
|
|
||||||
# You can construct set and dict comprehensions as well.
|
# 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}
|
{x: x**2 for x in range(5)} # => {0: 0, 1: 1, 2: 4, 3: 9, 4: 16}
|
||||||
|
|
||||||
|
|
||||||
@ -754,7 +753,7 @@ class Human:
|
|||||||
|
|
||||||
# Another instance method
|
# Another instance method
|
||||||
def sing(self):
|
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
|
# A class method is shared among all instances
|
||||||
# They are called with the calling class as the first argument
|
# 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.
|
# 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
|
# This __name__ check makes sure this code block is only executed when this
|
||||||
# module is the main program.
|
# module is the main program.
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
# Instantiate a class
|
# Instantiate a class
|
||||||
i = Human(name="Ian")
|
i = Human(name="Ian")
|
||||||
i.say("hi") # "Ian: hi"
|
i.say("hi") # "Ian: hi"
|
||||||
@ -849,7 +848,7 @@ class Superhero(Human):
|
|||||||
# pass
|
# pass
|
||||||
|
|
||||||
# Child classes can override their parents' attributes
|
# Child classes can override their parents' attributes
|
||||||
species = 'Superhuman'
|
species = "Superhuman"
|
||||||
|
|
||||||
# Children automatically inherit their parent class's constructor including
|
# Children automatically inherit their parent class's constructor including
|
||||||
# its arguments, but can also define additional arguments or definitions
|
# its arguments, but can also define additional arguments or definitions
|
||||||
@ -872,7 +871,7 @@ class Superhero(Human):
|
|||||||
|
|
||||||
# override the sing method
|
# override the sing method
|
||||||
def sing(self):
|
def sing(self):
|
||||||
return 'Dun, dun, DUN!'
|
return "Dun, dun, DUN!"
|
||||||
|
|
||||||
# add an additional instance method
|
# add an additional instance method
|
||||||
def boast(self):
|
def boast(self):
|
||||||
@ -880,14 +879,14 @@ class Superhero(Human):
|
|||||||
print("I wield the power of {pow}!".format(pow=power))
|
print("I wield the power of {pow}!".format(pow=power))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
sup = Superhero(name="Tick")
|
sup = Superhero(name="Tick")
|
||||||
|
|
||||||
# Instance type checks
|
# Instance type checks
|
||||||
if isinstance(sup, Human):
|
if isinstance(sup, Human):
|
||||||
print('I am human')
|
print("I am human")
|
||||||
if type(sup) is Superhero:
|
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()
|
# Get the "Method Resolution Order" used by both getattr() and super()
|
||||||
# (the order in which classes are searched for an attribute or method)
|
# (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!
|
print(sup.sing()) # => Dun, dun, DUN!
|
||||||
|
|
||||||
# Calls method from Human
|
# Calls method from Human
|
||||||
sup.say('Spoon') # => Tick: Spoon
|
sup.say("Spoon") # => Tick: Spoon
|
||||||
|
|
||||||
# Call method that exists only in Superhero
|
# Call method that exists only in Superhero
|
||||||
sup.boast() # => I wield the power of super strength!
|
sup.boast() # => I wield the power of super strength!
|
||||||
@ -913,33 +912,35 @@ if __name__ == '__main__':
|
|||||||
print(sup.age) # => 31
|
print(sup.age) # => 31
|
||||||
|
|
||||||
# Attribute that only exists within Superhero
|
# 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
|
## 6.2 Multiple Inheritance
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
|
|
||||||
# Another class definition
|
# Another class definition
|
||||||
# bat.py
|
# bat.py
|
||||||
class Bat:
|
class Bat:
|
||||||
|
|
||||||
species = 'Baty'
|
species = "Baty"
|
||||||
|
|
||||||
def __init__(self, can_fly=True):
|
def __init__(self, can_fly=True):
|
||||||
self.fly = can_fly
|
self.fly = can_fly
|
||||||
|
|
||||||
# This class also has a say method
|
# This class also has a say method
|
||||||
def say(self, msg):
|
def say(self, msg):
|
||||||
msg = '... ... ...'
|
msg = "... ... ..."
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
# And its own method as well
|
# And its own method as well
|
||||||
def sonar(self):
|
def sonar(self):
|
||||||
return '))) ... ((('
|
return "))) ... ((("
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == "__main__":
|
||||||
b = Bat()
|
b = Bat()
|
||||||
print(b.say('hello'))
|
print(b.say("hello"))
|
||||||
print(b.fly)
|
print(b.fly)
|
||||||
|
|
||||||
|
|
||||||
@ -959,17 +960,17 @@ class Batman(Superhero, Bat):
|
|||||||
# So instead we explicitly call __init__ for all ancestors.
|
# So instead we explicitly call __init__ for all ancestors.
|
||||||
# The use of *args and **kwargs allows for a clean way to pass
|
# The use of *args and **kwargs allows for a clean way to pass
|
||||||
# arguments, with each parent "peeling a layer of the onion".
|
# arguments, with each parent "peeling a layer of the onion".
|
||||||
Superhero.__init__(self, 'anonymous', movie=True,
|
Superhero.__init__(self, "anonymous", movie=True,
|
||||||
superpowers=['Wealthy'], *args, **kwargs)
|
superpowers=["Wealthy"], *args, **kwargs)
|
||||||
Bat.__init__(self, *args, can_fly=False, **kwargs)
|
Bat.__init__(self, *args, can_fly=False, **kwargs)
|
||||||
# override the value for the name attribute
|
# override the value for the name attribute
|
||||||
self.name = 'Sad Affleck'
|
self.name = "Sad Affleck"
|
||||||
|
|
||||||
def sing(self):
|
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()
|
sup = Batman()
|
||||||
|
|
||||||
# The Method Resolution Order
|
# The Method Resolution Order
|
||||||
@ -985,7 +986,7 @@ if __name__ == '__main__':
|
|||||||
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
|
# 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
|
# Call method that exists only in 2nd ancestor
|
||||||
print(sup.sonar()) # => ))) ... (((
|
print(sup.sonar()) # => ))) ... (((
|
||||||
@ -995,8 +996,7 @@ if __name__ == '__main__':
|
|||||||
print(sup.age) # => 100
|
print(sup.age) # => 100
|
||||||
|
|
||||||
# Inherited attribute from 2nd ancestor whose default value was overridden.
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
@ -1095,15 +1095,12 @@ print(my_function.__code__.co_argcount) # => 2
|
|||||||
|
|
||||||
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
||||||
* [The Official Docs](https://docs.python.org/3/)
|
* [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)
|
* [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/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](https://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](https://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [Dive Into Python 3](https://www.diveintopython3.net/index.html)
|
* [Dive Into Python 3](https://www.diveintopython3.net/)
|
||||||
* [A Crash Course in Python for Scientists](https://nbviewer.jupyter.org/gist/anonymous/5924718)
|
|
||||||
* [Python Tutorial for Intermediates](https://pythonbasics.org/)
|
* [Python Tutorial for Intermediates](https://pythonbasics.org/)
|
||||||
* [Build a Desktop App with Python](https://pythonpyqt.com/)
|
* [Build a Desktop App with Python](https://pythonpyqt.com/)
|
||||||
|
@ -15,7 +15,7 @@ filename: learnpython-ru.py
|
|||||||
почти что исполняемый псевдокод.
|
почти что исполняемый псевдокод.
|
||||||
|
|
||||||
Замечание: Эта статья относится только к Python 3.
|
Замечание: Эта статья относится только к Python 3.
|
||||||
Если вы хотите изучить Python 2.7, обратитесь к [другой статье](https://learnxinyminutes.com/docs/ru-ru/pythonlegacy-ru/).
|
Если вы хотите изучить Python 2.7, обратитесь к [другой статье](/docs/ru-ru/pythonlegacy-ru/).
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# Однострочные комментарии начинаются с символа решётки.
|
# Однострочные комментарии начинаются с символа решётки.
|
||||||
@ -45,7 +45,7 @@ filename: learnpython-ru.py
|
|||||||
5.0 // 3.0 # => 1.0 # работает и для чисел с плавающей запятой
|
5.0 // 3.0 # => 1.0 # работает и для чисел с плавающей запятой
|
||||||
-5.0 // 3.0 # => -2.0
|
-5.0 // 3.0 # => -2.0
|
||||||
|
|
||||||
# # Результат деления возвращает число с плавающей запятой
|
# Результат деления возвращает число с плавающей запятой
|
||||||
10.0 / 3 # => 3.3333333333333335
|
10.0 / 3 # => 3.3333333333333335
|
||||||
|
|
||||||
# Остаток от деления
|
# Остаток от деления
|
||||||
@ -125,7 +125,7 @@ b == a # => True, Объекты a и b равны
|
|||||||
"Это строка."
|
"Это строка."
|
||||||
'Это тоже строка.'
|
'Это тоже строка.'
|
||||||
|
|
||||||
# И строки тоже могут складываться! Хотя лучше не злоупотребляйте этим.
|
# И строки тоже могут складываться!
|
||||||
"Привет " + "мир!" # => "Привет мир!"
|
"Привет " + "мир!" # => "Привет мир!"
|
||||||
|
|
||||||
# Строки (но не переменные) могут быть объединены без использования '+'
|
# Строки (но не переменные) могут быть объединены без использования '+'
|
||||||
@ -168,8 +168,8 @@ bool(()) # => False
|
|||||||
# В Python есть функция Print
|
# В Python есть функция Print
|
||||||
print("Я Python. Приятно познакомиться!") # => Я Python. Приятно познакомиться!
|
print("Я Python. Приятно познакомиться!") # => Я Python. Приятно познакомиться!
|
||||||
|
|
||||||
# По умолчанию функция, print() также выводит новую строку в конце.
|
# По умолчанию, функция print() также выводит новую строку в конце.
|
||||||
# Используйте необязательный аргумент end, чтобы изменить последнюю строку.
|
# Используйте необязательный аргумент end, чтобы изменить конец последней строки.
|
||||||
print("Привет мир", end="!") # => Привет мир!
|
print("Привет мир", end="!") # => Привет мир!
|
||||||
|
|
||||||
# Простой способ получить входные данные из консоли
|
# Простой способ получить входные данные из консоли
|
||||||
@ -502,11 +502,11 @@ with open("myfile2.txt", "w+") as file:
|
|||||||
file.write(json.dumps(contents)) # Записывает объект в файл
|
file.write(json.dumps(contents)) # Записывает объект в файл
|
||||||
|
|
||||||
# Чтение из файла
|
# Чтение из файла
|
||||||
with open('myfile1.txt', "r+") as file:
|
with open("myfile1.txt", "r+") as file:
|
||||||
contents = file.read() # Читает строку из файла
|
contents = file.read() # Читает строку из файла
|
||||||
print(contents) # => '{"aa": 12, "bb": 21}'
|
print(contents) # => '{"aa": 12, "bb": 21}'
|
||||||
|
|
||||||
with open('myfile2.txt', "r") as file:
|
with open("myfile2.txt", "r") as file:
|
||||||
contents = json.load(file) # Читает объект json из файла
|
contents = json.load(file) # Читает объект json из файла
|
||||||
print(contents) # => {"aa": 12, "bb": 21}
|
print(contents) # => {"aa": 12, "bb": 21}
|
||||||
|
|
||||||
@ -1034,16 +1034,13 @@ print(say(say_please=True)) # Вы не купите мне пива? Пожа
|
|||||||
### Бесплатные онлайн-материалы
|
### Бесплатные онлайн-материалы
|
||||||
|
|
||||||
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
|
||||||
* [Официальная документация](http://docs.python.org/3/)
|
* [Официальная документация](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)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
* [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/)
|
* [Python Tutorial for Intermediates](https://pythonbasics.org/)
|
||||||
* [Build a Desktop App with Python](https://pythonpyqt.com/)
|
* [Build a Desktop App with Python](https://pythonpyqt.com/)
|
||||||
|
@ -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/)
|
* [Dive Into Python](http://www.diveintopython.net/)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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/)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.ipython.org/5920182)
|
|
||||||
* [Python Course](http://www.python-course.eu/index.php)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
||||||
|
|
||||||
### Kitaplar
|
### Kitaplar
|
||||||
|
@ -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)
|
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com)
|
||||||
* [The Official Docs](http://docs.python.org/3/)
|
* [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)
|
* [Python Course](http://www.python-course.eu/index.php)
|
||||||
* [First Steps With Python](https://realpython.com/learn/python-first-steps/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](http://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
* [Dive Into Python 3](http://www.diveintopython3.net/index.html)
|
||||||
* [A Crash Course in Python for Scientists](http://nbviewer.jupyter.org/gist/anonymous/5924718)
|
|
||||||
|
@ -9,7 +9,6 @@ translators:
|
|||||||
- ["Maple", "https://github.com/mapleincode"]
|
- ["Maple", "https://github.com/mapleincode"]
|
||||||
filename: learnpython-cn.py
|
filename: learnpython-cn.py
|
||||||
lang: zh-cn
|
lang: zh-cn
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Python 是由吉多·范罗苏姆(Guido Van Rossum)在 90 年代早期设计。
|
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 :(
|
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/)
|
* [Automate the Boring Stuff with Python](https://automatetheboringstuff.com/)
|
||||||
* [Ideas for Python Projects](http://pythonpracticeprojects.com/)
|
* [Ideas for Python Projects](http://pythonpracticeprojects.com/)
|
||||||
* [The Official Docs](https://docs.python.org/3/)
|
* [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/)
|
* [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/)
|
* [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)
|
* [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://peps.python.org/pep-0008/)
|
||||||
* [Official Style Guide for Python](https://www.python.org/dev/peps/pep-0008/)
|
|
||||||
* [Python 3 Computer Science Circles](https://cscircles.cemc.uwaterloo.ca/)
|
* [Python 3 Computer Science Circles](https://cscircles.cemc.uwaterloo.ca/)
|
||||||
* [Dive Into Python 3](https://www.diveintopython3.net/index.html)
|
* [Dive Into Python 3](https://www.diveintopython3.net/)
|
||||||
* [A Crash Course in Python for Scientists](https://nbviewer.jupyter.org/gist/anonymous/5924718)
|
|
||||||
* [Python Tutorial for Intermediates](https://pythonbasics.org/)
|
* [Python Tutorial for Intermediates](https://pythonbasics.org/)
|
||||||
* [Build a Desktop App with Python](https://pythonpyqt.com/)
|
* [Build a Desktop App with Python](https://pythonpyqt.com/)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user