meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
programming:python [2017/08/09 13:34] niziak |
programming:python [2020/07/03 09:51] (current) niziak ↷ Page moved from python to programming:python |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Python ====== | ||
+ | |||
====== OOP ====== | ====== OOP ====== | ||
+ | |||
===== Call parent constuctor ====== | ===== Call parent constuctor ====== | ||
Line 23: | Line 26: | ||
print("{firstname} {lastname}".format(firstname="Horst", lastname="Gutmann")) | print("{firstname} {lastname}".format(firstname="Horst", lastname="Gutmann")) | ||
</code> | </code> | ||
+ | |||
+ | * new f-strings in Python 3.6 | ||
+ | <code python> | ||
+ | name = 'Fred' | ||
+ | age = 42 | ||
+ | print(f'He said his name is {name} and he is {age} years old.') | ||
+ | </code> | ||
+ | |||
+ | ===== logger ===== | ||
+ | |||
+ | Logger is optimized to defer avaluation of arguments until it is needed, so for best performance use ''%'' formating. | ||
+ | Instead of this: | ||
+ | <code python>logger.error('oops caused by %s' % exc)</code> | ||
+ | do that: | ||
+ | <code python>logger.error('oops caused by %s', exc)</code> | ||
+ | |||
====== Exceptions ====== | ====== Exceptions ====== |