Joined September 2016
8 Photos and videos
And here you are: with opened connection, listening on a port, sending bytes, including some newline stuff
Terminal N2 - start listening to arbitrary port $ netcat -l 1234 T1 - connect to it, and send >> s.connect(('', 1234)) >> s.send(b'abc\n')
Terminal N1 -- create a socket, the place where bytes will go to >> import socket >> s = socket.socket()
Short but amazing (at least for me) intro to network programming. We start by opening two terminals: for python and netcat utility. #Python
3
Also, for only two dicts merge: >> {**dict_a, **dict_b}
or >> reduce(lambda acc, d: dict(acc, **d), [d1, d2])
Few ways to merge N dicts: # new_dct = {}; d1 = {'a': 1}; d2 = {'b': 2} >> map(new_dct.update, [d1, d2]) >> new_dct {'a': 1, 'b': 2} #Python
2
Don't do this: def hi(): print(‘hello’) def fraud(): print(‘bye’) hi.__code__ = fraud.__code__ hi() .... bye #Python
or we can look at it this way >> 2==2 , 3 (True, 3)
`==` comes before `,` : >> (1,) == 1 False # tuple not eq. to int And the final answer is (False,) # prev. expression and comma
Can you guess result of this expression? >> (1,) == 1, #Python
2
1
2
Ways to represent number in hex (`ff`): >> hex(255).lstrip('0x') >> '{:02x}'.format(255) >> format(255, '02x') #Python
Mystery solved. David Beazley on how he did slides for talks like youtube.com/watch?v=j6VSAsKA… Answer here: forum.dabeaz.com/t/how-to-mo… #Python

It works like ternary, e.g. 1 < x < 3
Answer: `TypeError: unorderable types: list() <= int()` Interestingly >> x[x==1] 1 Indexing: >> x[False] # x[0] 1 >> x[True] # x[1] 2
#Django 2.0 (now on master) will not support #Python 2: github.com/django/django/pul… github.com/django/django/pul… 🎉🍾✨😃

3
183
185
Question: what kind of error it will produce? >> x = [1,2,3,4,5] >> x[x<=1] #Python
1
you can be surprised by result of that: >> False is False is False ?? #Python
1
Function without body (noop) can be created by putting inside: pass """ docstring """ ... (ellipsis) #Python