list/tuple to dict...
pfortin at pfortin.com
Thu Sep 16 03:20:23 CEST 2004
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...?
> Why build the dictionary at all. Use the named attributes provided by
> mode = os.stat(f).st_mode
> That should meet the original readability goals.
That'll teach me to use examples that already have named attributes... :^)
I'm looking to do this generically -- ignore the few that do have named
attributes; there are plenty without that I'd like to address...
The goal is to use the dict in string mapping keys as indicated in my
More information about the Python-list