— Albert Einstein
https://losc.ligo.org/software/
wow
How old is Python?
>>> '{} years ago'.format(2016 - 1991)
'25 years ago'
How did Python get here?
Spanish arrived first
Spanish → ← English
Bruhella → Bree-Hill
Latin → ← Old Saxon
god, yule, holy
Lexical
>>> b = '\n'.join(
... ''.join(chr(j) for j in range(i, i+32))
... for i in range(32, 128, 32)
... )
>>> print b.decode('ascii')
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
>>> bytes_32_to_255 = '\n'.join(
... ''.join(chr(j) for j in range(i, i+32))
... for i in range(32, 256, 32)
... )
bytes_32_to_255.decode('latin1')
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
bytes_32_to_255.decode('greek8', 'replace')
!"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
‘’£€₯¦§¨©ͺ«¬�―°±²³΄΅Ά·ΈΉΊ»Ό½ΎΏ
ΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡ�ΣΤΥΦΧΨΩΪΫάέήί
ΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώ�
>>> email = u'cañon'.encode('latin1')
>>> print email.decode('greek8')
caΓ±on
symbol → number → bytes
cañon → canyon
C
↘
sh ↘
Python 1.0
ABC ↗
↗
Modula-3
sorted(set(user.surname for user in users))
C
↘
sh ↘
Python 1.0
ABC ↗
↗
Modula-3
sorted(set(user.name for user in users))
names = {}
for user in users:
names[user.surname] = None
names = names.keys()
names.sort()
Haskell Dylan
comprehensions MRO with!
↘ ↘ ↓
Python 2.0 2.2 2.3 2.4 2.5 …
↗ ↗
generators annotations
Icon Java
sorted(set(user.name for user in users))
cut -d" " -f1 users.txt | uniq | sort
'Hi, %s, you have %d messages.' % (name, n)
'Hi, {}, you have {} messages.'.format(name, n)
'The time is {:%H:%M}.'.format(datetime.now())
[u for u in users if u.age > 21]
filter(lambda u: u.age > 21, users)
[name.upper() for name in names]
map(str.upper, names)
'Without music, life would be a mistake'
"Without music, life would be a mistake"
rivers = [
'Yaque del Norte',
'Yaque del Sur'
]
↓
rivers = [
'Yaque del Norte',
'Yaque del Sur'
'Yuna River'
]
rivers = [
'Yaque del Norte',
'Yaque del Sur',
]
↓
rivers = [
'Yaque del Norte',
'Yaque del Sur',
'Yuna River',
]
with open('data.csv') as f:
lines = list(f)
if not lines:
return
count = len(lines)
new Integer(3.0); int(3.0)
(int) height; int(height)
method('/'); method('/')
int r = printf("Hello, world!");
if (r == -1) {
return NULL;
}
def f():
print "Hello, world!"
try:
f()
except IOError:
…
$ awk 'END {print 30 + "40"}'
70
$ perl -e 'print 30 + "40"'
70
js> '30' + 40
'3040'
js> '30' - 40
-10
>>> '30' + 40
Traceback (most recent call last):
...
TypeError: cannot concatenate 'str'
and 'int' objects
>>> import this