In [15]:
import sys
print(sys.version)
In [1]:
print "is no longer a statement"
In [5]:
type(range(5)) is list
Out[5]:
In [9]:
1 / 2 == 0 # WHY??!!
Out[9]:
In [16]:
# methods for looping through dictionaries are iterators by default
mydict = {'a': 1, 'b': 2, 'c': 3}
for key, value in mydict.iteritems():
print key, value
In [8]:
# is it a feature or a bug?!
'a' < 1
Out[8]:
In [4]:
# magic dictionary concatenation
some_kwargs = {'do': 'this',
'not': 'that'}
other_kwargs = {'use': 'something',
'when': 'sometime'}
{**some_kwargs, **other_kwargs}
In [5]:
# unpacking magic
a, *stuff, b = range(5)
print(a)
print(stuff)
print(b)
In [17]:
# no unicode variable names
π = 1
In [19]:
# no infix matrix multiplication
import numpy as np
A = np.random.choice(list(range(-9, 10)), size=(3, 3))
B = np.random.choice(list(range(-9, 10)), size=(3, 3))
A @ B
In [6]:
# will print tuple and will truncate division operation
print('non-truncated division in a print function: 2/3 =', 2/3)
In [7]:
from __future__ import print_function, division
print('non-truncated division in a print function: 2/3 =', 2/3)