Importing two module variables and having one clobber the other?

Mike Mazurek mike.mazurek at gmail.com
Wed Mar 22 11:06:44 CET 2006


You could wrap your paramter dict in a class instance with something like:

class Parameters(object):
    def __init__(self, parameterDict):
        self.__dict__ = parameterDict.copy()
        # NB: copying may not be necissary for your case

parms = Parameters(dict(a=1,b=2,c=3))
print parms.a, parms.b, parms.c


On 21 Mar 2006 14:05:49 -0800, Joseph Turian <turian at gmail.com> wrote:
>
>
> Fredrik Lundh wrote:
>
> > if you prefer to use a "parameters.value" syntax, you can wrap the
> resulting
> > dictionary in a class.
>
> That sounds good. How do I do that?
>
> > I assume "from" means "beneath" and "getcwd" means "walk" ?
>
> Actually:
> def superdirs(d):
>   lst = [d]
>   while d != os.environ["HOME"]:
>     (d, tl) = os.path.split(d)
>     lst += [d]
>   lst.reverse()
>   return lst
>
>
>    Joseph
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060322/198353ef/attachment.html>


More information about the Python-list mailing list