list/tuple to dict...
Raymond Hettinger
vze4rx4y at verizon.net
Wed Sep 15 18:58:26 EDT 2004
[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,ctime")
[Diez B. Roggisch]
> Use
>
> dict(zip(["mode,inode,dev,nlink,uid,gid,size,atime,mtime,ctime"],
> os.stat("%s" % path)))
Why build the dictionary at all. Use the named attributes provided by os.stat:
mode = os.stat(f).st_mode
That should meet the original readability goals.
Raymond Hettinger
More information about the Python-list
mailing list