by reference

dirvine irvine.david at gmail.com
Wed Feb 15 18:53:18 EST 2006


Many thanks Martin

You right - possible and ugly. Looks  like I will doing a from
__future__ as it looks better and perhaps this ugly method may be
depreciated.

Thanks again for your help
David
Martin P. Hellwig wrote:
> dirvine wrote:
> > Yes I did
> >
> > I was trying to do something like (pseudo code)
> >
> > write:
> > get files in path
> > for each filename get size, type
> > create dic called filename assign size:xx,type:y
> > pickle to file
> >
> > read:
> > open pickled file
> > read dict name and contents (hoping unpickling file gives me the dict
> > name as it was saved, which may not be true)
> > do stuff with file
> >
> >
> > and thats it. My prog is a bit more complex than this but this is the
> > general idea basically read files -> create dicts of files one at a
> > time, very similar to bittorrent in that take a file smash to bits and
> > store links to bits in a big file.
> >
> > Many thanls
> > David
> >
>
> Well, although I still think you should use nested dicts doesn't say
> that what you want isn't possible, take a look at this snippet:
>  >>> locals()['test']=dict()
>  >>> test
> {}
>  >>>
> It looks quite ugly too me but that is probably in the eye of the
> beholder. However even the faq has some info on that:
> http://www.python.org/doc/faq/programming.html#how-do-i-use-strings-to-call-functions-methods
> 
> -- 
> mph




More information about the Python-list mailing list