[Tutor] Properties of an object
alan.gauld at btinternet.com
Sat Jan 31 00:25:09 CET 2009
> Python 2.x can add new methods to a user-defined class or instance or
> redefine existing methods.
> In : def sayFoo(self): print 'foo'
> In : Data.sayFoo = sayFoo
> In : d1.sayFoo()
Now for some reason I was sure that didn't work. So sure I never even tried!
(despite my comments in another thread about experimenting with
the >>> prompt!)
> The introduction of Abstract Base Classes in Python 2.6 and 3.0 seems
> intended to remedy this, giving you a way to specify an interface in
> the language:
I only downloaded v 3 a week or so ago and just spotted the ABC
reference last week. I haven't looked at it yet so it will be interesting
to see if you can do that.
More information about the Tutor