{twitter.com,
github.com,
youtube.com
}/turicas
turicas.info
alvaro@CursoDeArduino.com.br
www.CursoDeArduino.com.br
emap.fgv.br
Python developers are hash-addicted.
i = 42 # inteiro f = 3.14 # ponto flutuante c = 1.5 + 5.3j # complexo! s = "Fortal" # string t = (1, "python") # tupla l = [1, 2.3, "ab", [1, "b"]] # lista d = {'a': 1, 2: 'b', (1, 2): [3, 4]} # dicionário
>>> my_dict = {} >>> my_dict['key'] = 'value' >>> my_dict['key2'] = 42 >>> 'key' in my_dict True >>> my_dict.keys() ['key2', 'key'] >>> my_dict['key'] 'value' >>> for key, value in my_dict.items(): print key, value key2 42 key value >>> del my_dict['key'] >>> my_dict.values() [42] >>> my_dict = {k: v for k, v in zip('123', '456')}
"three little birds"
"every little thing"
token | documento |
---|---|
three | doc1 |
little | doc1, doc2 |
birds | doc1 |
every | doc2 |
thing | doc2 |
Talk is cheap, show me the code!
gdbm
>>> import gdbm # standard library >>> persistent_dict = gdbm.open('test.dbm', 'c') >>> persistent_dict['python'] = 'rules' >>> persistent_dict[u'Álvaro'] = 'Turicas' TypeError: gdbm mappings have string indices only >>> persistent_dict['Turicas'] = u'Álvaro' TypeError: gdbm mappings have string elements only
shelve
shelve in stdlib == True
shelve == gdbm + pickle
pickle
? pymongo
mongodict
dict
s on steroidsdict
that speaks many languages
>>> translate('vortaroj', from='eo', to='pt') 'dicion\xc3\xa1rios'
2 a 4 de outubro de 2013
,
Brasília/DF
?
{twitter.com,
github.com,
youtube.com
}/turicas
turicas.info
alvaro@CursoDeArduino.com.br
www.CursoDeArduino.com.br