Generic constructors and duplication of internal Python logic

Michele Simionato michele.simionato at poste.it
Wed Apr 28 10:19:56 EDT 2004


sdementen at hotmail.com (Sebastien de Menten) wrote in message news:<8dad5312.0404280217.21c2cfd1 at posting.google.com>...
> Here is a metaclass for uber-lazy user :-)
> 
> Concretely, at the creation of the class it takes the source of the
> __init__ function and add, at the first line of __init__, the line
> that sets the attributes :
> >         self.foo, self.bar, self.baz, self.optional1, self.optional2 = 
> >                    foo, bar, baz, optional1, optional2
> 

Unfortunately this approach does not work if the source is not available
(this happens when you are in the interpreter, or when you only have a .pyc 
file). I was playing this kind of tricks some time ago, then I decided that
it was best to switch to Lisp/Scheme for this kind of stuff ;)


  Michele Simionato



More information about the Python-list mailing list