[pyar] Medio OT: Diccionario...
Roberto Alsina
ralsina en netmanagers.com.ar
Vie Ene 28 10:35:28 ART 2011
On 1/28/2011 10:34 AM, Roberto Alsina wrote:
> On 1/28/2011 10:31 AM, Roberto Alsina wrote:
>> >>> defs = {}
>> >>> for line in testdata.splitlines():
>> if line and line[0].isalphanumeric():
>> print line
> Oops, pegué el fragmento equivocado!
>
> >>> defs = {}
> >>> for line in testdata.splitlines():
> if line and line[0].isalnum():
> key = line
> definition = []
> defs[key]=[]
> elif key:
> defs[key].append(line)
>
>
> Y ahora todo el mundo sabe que mis primeros intentos de hacer código
> trivial están llenos de errores! Mi imagen!
Demonios!
>>> key = None
>>> defs = {}
>>> for line in testdata.splitlines():
if line and line[0].isalnum():
key = line
definition = []
defs[key]=[]
elif key:
defs[key].append(line)
More information about the pyar
mailing list