list/tuple to dict...
Diez B. Roggisch
deetsNOSPAM at web.de
Thu Sep 16 06:47:16 EDT 2004
Pierre Fortin wrote:
> On Wed, 15 Sep 2004 22:58:26 GMT Raymond wrote:
>
>> [Pierre Fortin]
>> > > I'm just looking to make my code more readable and
>> > > self-documenting...
>> . . .
>> > > osstat = todict(os.stat("%s" % path),
>> > > "mode,inode,dev,nlink,uid,gid,size,atime,mtime,ctim
>> > > e")
>>
>> [Diez B. Roggisch]
>> > Use
>> >
>> > dict(zip(["mode,inode,dev,nlink,uid,gid,size,atime,mtime,ctime"],
>> > os.stat("%s" % path)))
>
> What does zip() have to do with this situation...?
Uhm - its needed?
It creates a list of pairs from the two argument lists, and dict() takes a
list of pairs of (key, value) to form a dictionary.
--
Regards,
Diez B. Roggisch
More information about the Python-list
mailing list