Python-idioms-2014-01-16.pdf
(
132 KB
)
Pobierz
Python Idioms
Safe Hammad
Python Northwest
16
th
January 2014
What is an idiom?
“The speciic grammatical, syntactic, and
structural character of a given language.”
“A commonly used and understood way of
expressing an fact, idea or intention.”
Why care about Python idioms?
"Programs must be written for people to read, and
only incidentally for machines to execute."
- Abelson & Sussman, SICP
“There should be one - and preferably only one -
obvious way to do it.”
-
Tim Peters, The Zen of Python (PEP 20)
●
The use of commonly understood syntax or coding
constructs can aid readability and clarity.
●
Some idioms can be faster or use less memory than
their “non-idiomatic” counterparts.
●
Python's idioms can make your code Pythonic!
Ten idioms
(In no particular order)
1. Make a script both
importable and executable
if __name__ == '__main__':
Plik z chomika:
chomiczekipliczek
Inne pliki z tego folderu:
Python-idioms-2014-01-16.pdf
(132 KB)
Think Python.pdf
(815 KB)
Introduction to Computation and Programming Using Python -nelly-.pdf
(21856 KB)
Python In A Nutshell 2nd Edition V413HAV.pdf
(21915 KB)
Learning Python 5th Ed 2013.pdf
(14809 KB)
Inne foldery tego chomika:
Django Tuts
Flask Tutorial
Google Class Python
Kivy Tutorial
LearnPython
Zgłoś jeśli
naruszono regulamin