Python has type annotations since 3.5:
def greater_than_10(a:int) -> bool:
return a > 10
class Tank:
def __init__(self):
self.fill = 0
def tank(self, amount:float):
return(self.fill += amount)
See also: the typing module documentation.
UIView
has a method addSubviews(_ views:[UIView])
which allows to add more than one view at once. It's not in the documentation.
How to use IPython Shell as Django shell.
If you are in a virtualenv, be sure to install ipython
with
$ pip install ipython
Then start the Django shell with
$ python admin.py -i shell
explicit relative imports:
from .models import WaffleCone # use when importing from another module in the current app
Efficient renaming without changing the Path. In my ~/Downloads
directory, I wanted to reanme the file annotatet
to annotated
. Of course, I could cd
to ~/Downloads
and do the renaming there, but instead I used the Brace Expansion feature of Bash:
$ mv ~/Downloads/annotate{t,d}_offer.png
This is also useful for e.g. creating paths with a common prefix and the braces can also be nested:
$ echo ers{etzen,atz{zahnrad,fahrrad}}
expands to:
ersetzen ersatzzahnrad ersatzfahrrad