Subclassing builtins or another alternative

Courageous jkraska at san.rr.com
Tue Dec 11 19:30:04 EST 2001


I have an external C-extension type. Let's call it "Agent".

I would like to allow coders using Agent to use it syntactically
as a normal baseclass. For example,

import agent

class Pilot ( agent.Agent ):
	i=3
	def f(self):
		pass

Misfortunately, either one can't do this or I simply misunderstand
what to hook up in the extension. Neither the setattr() or setattro()
methods appear to get invoked by either the class-level data
assignment of "i=3" or the definition of the f method on the class.

What, by the way, are the difference between setattr() and setattro()?

And can I do what I'm trying to do? If so, how?

If read some of the xxsubclass code and the like, but I'm still not
grokking.

C//




More information about the Python-list mailing list