Re: [Tutor] Metaclass programming

2007-09-05 Thread Kent Johnson
Orest Kozyar wrote: You're right. I just figured out that for some reason, when I use the SQLAlchemy mapper() function to map my classes to the corresponding table object, it seems to affect inspect.getargspec(). For example: from sqlalchemy.orm import mapper from sqlalchemy import

Re: [Tutor] Metaclass programming

2007-09-04 Thread Kent Johnson
Orest Kozyar wrote: I have the following code: class meta(type): def __call__(cls, *args, **kwargs): argnames = inspect.getargspec(cls.__init__)[0] for i, value in enumerate(args): kwargs[argnames[i]] = value This could be written

Re: [Tutor] Metaclass programming

2007-09-04 Thread Orest Kozyar
This could be written kwargs.update(zip(argnames, args)) Nice trick! Thanks for the pointer. return type.__call__(cls, kwargs) You are passing kwargs as a positional argument to __call__(); i.e. passing the dict as an ordinary parameter. To use kwargs as the keyword

[Tutor] Metaclass programming

2007-09-03 Thread Orest Kozyar
I have the following code: class meta(type): def __call__(cls, *args, **kwargs): argnames = inspect.getargspec(cls.__init__)[0] for i, value in enumerate(args): kwargs[argnames[i]] = value return type.__call__(cls,