[Tutor] question about classes and atributes
alan.gauld at btinternet.com
Sat Nov 4 01:21:43 CET 2006
"Kent Johnson" <kent37 at tds.net> wrote
> Alan Gauld wrote:
>> I'm not sure about adding methods at run time, I've never
> Sure it works:
> In : class foo(object): pass
> In : def show(self): print "Hi, I'm a foo"
> In : foo.show=show
> In : f.show()
> Hi, I'm a foo
I'm constantly amazed at the power and simplicity of Python.
> More advanced explanation:
Yes, it makes sense when its explained.
But I'd never have intuitively thought of that!
Thanks for the info Kent.
More information about the Tutor