Class Factories in Python: How?

Andrew Csillag drew.csillag at starmedia.net
Mon May 1 15:33:44 EDT 2000


Sounds like you probably want metaclasses.  See
http://www.python.org/doc/essays/metaclasses/.

In short, what metaclasses allow you to do is to turn a class definition
into a function call (at which time you can do whatever).  Warning: it
can make your head explode, but can save a bunch of work if used
properly.
-- 
print(lambda(q,p):'pmt:$%0.2f'%(q*p/(p-1)))((lambda(a,r,n),t:(a*r/
t,pow(1+r/t,n*12)))(map(input,('amt:','%rate:','years:')),1200.0))




More information about the Python-list mailing list