Python is an interpreted, interactive, object-oriented programming language
Is kind of a tool you start to use and never look back
https://www.python.org
# python for nonprogrammers
https://wiki.python.org/moin/BeginnersGuide/NonProgrammers
# python for programmers
https://wiki.python.org/moin/BeginnersGuide/Programmers
# official docs
https://docs.python.org/3/tutorial/
# The Hitchhiker’s Guide to Python!
http://docs.python-guide.org/en/latest/
# automate the boring stuff
https://automatetheboringstuff.comPEP 0 - index of PEPs
PEP 8 - Code style guide
PEP 20 - The Zen of Python
PEP 405 - Virtual Envrionments
PEP 484 - Type Hints
Python Enhancement Proposals
>>> import this$ python3The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!# in:
def very_important_function(template: str, *variables, file: os.PathLike, debug: bool = False):
"""Applies `variables` to the `template` and writes to `file`."""
with open(file, 'w') as f:
...
# out:
def very_important_function(
template: str,
*variables,
file: os.PathLike,
debug: bool = False,
):
"""Applies `variables` to the `template` and writes to `file`."""
with open(file, "w") as f:
...
# Scroll for more
# in:
l = [1,
2,
3,
]
# out:
l = [1, 2, 3]
# in:
l = [[n for n in list_bosses()], [n for n in list_employees()]]
# out:
l = [
[n for n in list_bosses()], [n for n in list_employees()]
]├── module_1.py
├── module_2.py
└── package (DIR)
├── __init__.py
└── module_in_package.py
def function_with_pep484_type_annotations(param1: int) -> int:
"""Example function with PEP 484 type annotations.
The return type must be duplicated in the docstring to comply
with the NumPy docstring style.
Parameters
----------
param1
The first parameter.
Returns
-------
int
True if successful, False otherwise.
"""
return param1I believe in it.
All labs also at: http://jans-workshops.gitlab.io/all-in-one/