PYWAT
АЛЕКСАНДР ШВЕЦ
>>> [1,2,3] == sorted([1,2,3])
>>> [1,2,3] == sorted([1,2,3])
True
>>> [1,2,3] == sorted([1,2,3])
True
>>> (1,2,3) == sorted((1,2,3))
>>> [1,2,3] == sorted([1,2,3])
True
>>> (1,2,3) == sorted((1,2,3))
False
>>> [1,2,3] == sorted([1,2,3])
True
>>> (1,2,3) == sorted((1,2,3))
False
>>> a = 2, 1, 3
>>> a = 2, 1, 3
>>> sorted(a) == sorted(a)
>>> a = 2, 1, 3
>>> sorted(a) == sorted(a)
True
>>> a = 2, 1, 3
>>> sorted(a) == sorted(a)
True
>>> reversed(a) == reversed(a)
>>> a = 2, 1, 3
>>> sorted(a) == sorted(a)
True
>>> reversed(a) == reversed(a)
False
>>> a = 2, 1, 3
>>> sorted(a) == sorted(a)
True
>>> reversed(a) == reversed(a)
False
>>> b = reversed(a)
>>> sorted(b) == sorted(b)
>>> a = 2, 1, 3
>>> sorted(a) == sorted(a)
True
>>> reversed(a) == reversed(a)
False
>>> b = reversed(a)
>>> sorted(b) == sorted(b)
False
>>> a = 2, 1, 3
>>> sorted(a) == sorted(a)
True
>>> reversed(a) == reversed(a)
False
>>> b = reversed(a)
>>> sorted(b) == sorted(b)
False
>>> a = ([],)
>>> a = ([],)
>>> a[0].extend([1])
>>> a = ([],)
>>> a[0].extend([1])
>>> a[0]
>>> a = ([],)
>>> a[0].extend([1])
>>> a[0]
[1]
>>> a = ([],)
>>> a[0].extend([1])
>>> a[0]
[1]
>>> a[0] += [2]
>>> a = ([],)
>>> a[0].extend([1])
>>> a[0]
[1]
>>> a[0] += [2]
TypeError: 'tuple' object does not
support item assignment
>>> a = ([],)
>>> a[0].extend([1])
>>> a[0]
[1]
>>> a[0] += [2]
TypeError: 'tuple' object does not
support item assignment
>>> a[0]
>>> a = ([],)
>>> a[0].extend([1])
>>> a[0]
[1]
>>> a[0] += [2]
TypeError: 'tuple' object does not
support item assignment
>>> a[0]
[1, 2]
>>> a = ([],)
>>> a[0].extend([1])
>>> a[0]
[1]
>>> a[0] += [2]
TypeError: 'tuple' object does not
support item assignment
>>> a[0]
[1, 2]
>>> isinstance(type, object)
>>> isinstance(type, object)
True
>>> isinstance(type, object)
True
>>> isinstance(object, type)
>>> isinstance(type, object)
True
>>> isinstance(object, type)
True
>>> isinstance(type, object)
True
>>> isinstance(object, type)
True
>>> all([])
>>> all([])
True
>>> all([])
True
>>> all([[]])
>>> all([])
True
>>> all([[]])
False
>>> all([])
True
>>> all([[]])
False
>>> all([[[]]])
>>> all([])
True
>>> all([[]])
False
>>> all([[[]]])
True
>>> all([])
True
>>> all([[]])
False
>>> all([[[]]])
True
>>> sum("")
>>> sum("")
0
>>> sum("")
0
>>> sum("", ())
>>> sum("")
0
>>> sum("", ())
()
>>> sum("")
0
>>> sum("", ())
()
>>> sum("", [])
>>> sum("")
0
>>> sum("", ())
()
>>> sum("", [])
[]
>>> sum("")
0
>>> sum("", ())
()
>>> sum("", [])
[]
>>> sum("", {})
>>> sum("")
0
>>> sum("", ())
()
>>> sum("", [])
[]
>>> sum("", {})
{}
>>> sum("")
0
>>> sum("", ())
()
>>> sum("", [])
[]
>>> sum("", {})
{}
>>> sum("", "")
>>> sum("")
0
>>> sum("", ())
()
>>> sum("", [])
[]
>>> sum("", {})
{}
>>> sum("", "")
TypeError: sum() can't sum strings
>>> sum("")
0
>>> sum("", ())
()
>>> sum("", [])
[]
>>> sum("", {})
{}
>>> sum("", "")
TypeError: sum() can't sum strings
>>> a = 1
>>> a = 1
>>> def foo():
>>> return a
>>> foo()
>>> a = 1
>>> def foo():
>>> return a
>>> foo()
1
>>> a = 1
>>> def foo():
>>> return a
>>> foo()
1
>>> def bar():
>>> a += 1
>>> return a
>>> bar()
>>> a = 1
>>> def foo():
>>> return a
>>> foo()
1
>>> def bar():
>>> a += 1
>>> return a
>>> bar()
UnboundLocalError: local variable 'a'
referenced before assignment
>>> a = 1
>>> def foo():
>>> return a
>>> foo()
1
>>> def bar():
>>> a += 1
>>> return a
>>> bar()
UnboundLocalError: local variable 'a'
referenced before assignment
>>> x = float("nan")
>>> y = float("nan")
>>> x = float("nan")
>>> y = float("nan")
>>> x == x
>>> x = float("nan")
>>> y = float("nan")
>>> x == x
False
>>> x = float("nan")
>>> y = float("nan")
>>> x == x
False
>>> [x] == [x]
>>> x = float("nan")
>>> y = float("nan")
>>> x == x
False
>>> [x] == [x]
True
>>> x = float("nan")
>>> y = float("nan")
>>> x == x
False
>>> [x] == [x]
True
>>> [x] == [y]
>>> x = float("nan")
>>> y = float("nan")
>>> x == x
False
>>> [x] == [x]
True
>>> [x] == [y]
False
>>> x = float("nan")
>>> y = float("nan")
>>> x == x
False
>>> [x] == [x]
True
>>> [x] == [y]
False
>>> a = 100
>>> b = 100
>>> a = 100
>>> b = 100
>>> a is b
>>> a = 100
>>> b = 100
>>> a is b
True
>>> a = 100
>>> b = 100
>>> a is b
True
>>> a = 300
>>> b = 300
>>> a = 100
>>> b = 100
>>> a is b
True
>>> a = 300
>>> b = 300
>>> a is b
>>> a = 100
>>> b = 100
>>> a is b
True
>>> a = 300
>>> b = 300
>>> a is b
False
>>> a = 100
>>> b = 100
>>> a is b
True
>>> a = 300
>>> b = 300
>>> a is b
False
>>> a, b = 300, 300
>>> a is b
>>> a = 100
>>> b = 100
>>> a is b
True
>>> a = 300
>>> b = 300
>>> a is b
False
>>> a, b = 300, 300
>>> a is b
True
>>> a = 100
>>> b = 100
>>> a is b
True
>>> a = 300
>>> b = 300
>>> a is b
False
>>> a, b = 300, 300
>>> a is b
True
>>> x, y = ???
>>> x + y == y + x
False
[0], [1]
>>> x, y = ???
>>> min(x, y) == min(y, x)
False
{0}, {1}
>>> x = ???
>>> x < x
True
https://github.com/cosmologicon/pywat
СПАСИБО
fb.com/ashwets
ashvets@mymary.ru
Александр Швец
технический директор
системы Marilyn

«PyWat. А хорошо ли вы знаете Python?» Александр Швец, Marilyn System