Re: An object that creates (nested) attributes automatically on assignment

2009-04-11 Thread Edd
On Apr 11, 12:54 pm, Steven D'Aprano wrote: > Ah, now it is more clear. > > Okay, let's try this: > > >>> class C(object): > > ...     def __getattr__(self, name): > ...             # Only called if self.name doesn't exist. > ...             inst = self.__class__() > ...             setattr(self,

Re: An object that creates (nested) attributes automatically on assignment

2009-04-11 Thread Steven D'Aprano
On Sat, 11 Apr 2009 03:01:48 -0700, Edd wrote: > Yes I probably mean instance attributes. Forgive me, I am not > particularly sure of the terminology. But your MyClass example, won't > quite do what I want, as I'd like to be able to define instance > attributes on top of instance attributes by ass

Re: An object that creates (nested) attributes automatically on assignment

2009-04-11 Thread Edd
Hi Steven, Thank you for your response! On Apr 11, 4:22 am, Steven D'Aprano wrote: > On Fri, 10 Apr 2009 19:04:38 -0700, Edd wrote: > > Hi folks, > > > I'd like to use Python itself as the configuration language for my > > Python application. I'd like the user to be able to write something like

Re: An object that creates (nested) attributes automatically on assignment

2009-04-11 Thread John Machin
On Apr 11, 1:22 pm, Steven D'Aprano wrote: > Is "pants" slang for "fragile, hard to understand and difficult to debug"? pommy slang for "sucks intensely, like the Deathstar's tractor beam" ... I think we agree with him. -- http://mail.python.org/mailman/listinfo/python-list

Re: [rfc] An object that creates (nested) attributes automatically on assignment

2009-04-10 Thread Steven D'Aprano
On Fri, 10 Apr 2009 19:04:38 -0700, Edd wrote: > Hi folks, > > I'd like to use Python itself as the configuration language for my > Python application. I'd like the user to be able to write something like > this in their config file(s): > >cfg.laser.on = True >cfg.laser.colour = 'blue' >

[rfc] An object that creates (nested) attributes automatically on assignment

2009-04-10 Thread Edd
Hi folks, I'd like to use Python itself as the configuration language for my Python application. I'd like the user to be able to write something like this in their config file(s): cfg.laser.on = True cfg.laser.colour = 'blue' cfg.discombobulated.vegetables = ['carrots', 'broccoli'] #