Create classes at runtnime

Chris Rebert clp2 at rebertia.com
Fri Feb 4 21:49:06 EST 2011


On Fri, Feb 4, 2011 at 6:10 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Fri, 04 Feb 2011 17:19:23 -0800, Ian wrote:
>> On Feb 4, 5:49 pm, Steven D'Aprano <steve
>> +comp.lang.pyt... at pearwood.info> wrote:
>>> Just add in the class attributes you want after creating the class.
> [...]
>> This would probably cause some problems with the Django metaclass.  It
>> inspects the class dictionary for fields at the time the class in
>> constructed, and so it would miss any fields added after construction
>> time.
>
> What Django metaclass? The OP didn't say anything about using Django.

His code mentions "forms.CharField" and declares a nested class named
"Meta"; this is indicative of Django.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list