[pyar] Medio OT: Diccionario...
Rodolfo Hugo González
lu8ekg en gmail.com
Vie Ene 28 12:23:10 ART 2011
El 28/01/11 10:35, Roberto Alsina escribió:
> 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)
>
Probando probando....
Gracias por el script. Ya veremos dijo Lemos... Un abrazo y éxito.
Rolfo
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20110128/e3a80bae/attachment.sig>
More information about the pyar
mailing list