526) f-strings (PEP 498) introduction of underscores in numeric literals, e.g. 1_000 (PEP 515) python 3.7 postponed evaluation of annotations via from __future__ import annotations (PEP 563) sort order of dicts is now guaranteed introduction of breakpoint, additionally to import pdb;pdb.set_trace() (PEP 553) introduction of data classes (PEP 557) python 3.8 introduction of the walrus operator (PEP 572) python 3.9 builtin generic types, that means you can use list and dict for type annotations, instead of importing e.g. from typing import List (PEP 585) eumiro 9
'Field {} contains value {!r}'.format(field, value) f'Field {field} contains value {value!r}' log.info('Field %s contains value %r', field, value) # -*- coding: latin-1 -*- func("���") func("\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd") "Šedivý" "\u0160ediv\00fd" "\N{LATIN CAPITAL LETTER S WITH CARON}ediv\N{LATIN SMALL LETTER Y WITH ACUTE}" eumiro 11
man.” — Leopold Kronecker >>> 9_007_199_254_740_993.0 9_007_199_254_740_992.0 number of nanoseconds in 105 days >>> 0.1 + 0.1 + 0.1 0.30000000000000004 eumiro 14
man.” — Leopold Kronecker >>> 9_007_199_254_740_993.0 9_007_199_254_740_992.0 number of nanoseconds in 105 days >>> 0.1 + 0.1 + 0.1 0.30000000000000004 >>> sum(0.3 for _ in range(1_000_000)) # 50ms 299999.99999434233 eumiro 14
man.” — Leopold Kronecker >>> 9_007_199_254_740_993.0 9_007_199_254_740_992.0 number of nanoseconds in 105 days >>> 0.1 + 0.1 + 0.1 0.30000000000000004 >>> sum(0.3 for _ in range(1_000_000)) # 50ms 299999.99999434233 >>> sum(decimal.Decimal('0.3') for _ in range(1_000_000)) # 350ms Decimal('300000.0') eumiro 14
man.” — Leopold Kronecker >>> 9_007_199_254_740_993.0 9_007_199_254_740_992.0 number of nanoseconds in 105 days >>> 0.1 + 0.1 + 0.1 0.30000000000000004 >>> sum(0.3 for _ in range(1_000_000)) # 50ms 299999.99999434233 >>> sum(decimal.Decimal('0.3') for _ in range(1_000_000)) # 350ms Decimal('300000.0') >>> sum(fractions.Fraction(3, 10) for _ in range(1_000_000)) # 3s Fraction(300000, 1) eumiro 14
= os.path.splitext(fn) if ext == '.csv': fname = os.path.join(parent, fn) with open(fname, 'rb') as f: data = f.read() process(data) for path in Path('/data').glob('*.csv'): process(path.read_bytes()) eumiro 19
= os.path.splitext(fn) if ext == '.csv': fname = os.path.join(parent, fn) with open(fname, 'rb') as f: data = f.read() process(data) for path in Path('/data').glob('*.csv'): process(path.read_bytes()) if path.exists(): path.unlink() # and since Python 3.8: path.unlink(missing_ok=False) eumiro 19
someone uses a feature you don't understand, simply shoot them. This is easier than learning something new, and before too long the only living coders will be writing in an easily understood, tiny subset of Python 0.9.6 . — Tim Peters, 2002 24
someone uses a feature you don't understand, simply shoot them. This is easier than learning something new, and before too long the only living coders will be writing in an easily understood, tiny subset of Python 0.9.6 . — Tim Peters, 2002 Miroslav Šedivý eumiro 24