[Tutor] Properties of an object

ALAN GAULD 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 [6]: def sayFoo(self): print 'foo'
> In [7]: Data.sayFoo = sayFoo
> In [8]: d1.sayFoo()
> foo

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.

Alan G.

More information about the Tutor mailing list