Pre-PEP ideas

Steven Taschuk staschuk at telusplanet.net
Mon Feb 17 04:29:34 CET 2003


Quoth Steven Cummings:
> 1. Separate Definition (or Dynamic Addition) of Methods
> 
> My specific idea is to allow the definition of methods outside of
> the class's main definition.  This would allow a class to be
> dynamically constructed based on conditional constructs.  [...]

Already there, if I understand what you want:

	>>> class A:
	...     pass
	...
	>>> def foo(self):
	...     print 'spam'
	...
	>>> A.foo = foo
	>>> a = A()
	>>> a.foo()
	spam

-- 
Steven Taschuk           |   ,\
staschuk at telusplanet.net | }<__`O=
                         |  '  "     Pleiosaur





More information about the Python-list mailing list