overriding methods - two questions
Donn Ingle
donn.ingle at gmail.com
Fri Nov 16 23:47:18 EST 2007
>> While technically possible (using inspect.getargspec), trying to make
>> your code idiot-proof is a lost fight and a pure waste of time.
> Worse: it's actually counter-productive!
> The whole idea of being able to subclass a class means that the user
> should be able to override foo() *including* the signature.
Steven,
In this case, the def in question is named Draw. It's args are context and
framenumber. The body is 'pass'. I want users to use the exact signature
(but they can change the varnames to suit) because the draw() method is
*not* being called by the user but *by* my API (in a timeout loop).
So, my API is sending blah.Draw( cairo.context, currentFrame ) *to* the
user's own object.Draw.Thereafter, whatever Cairo drawing commands they use
in their override of Draw() is what gets drawn -- if that makes sense :)
I guess that's the long way of saying it's a call-back function :)
So, I'm trying to guarantee that they don't mess with it to make life easier
for them. As Bruno has mentioned, this is up to the human and so it'll be a
rule in the docs instead.
/d
More information about the Python-list
mailing list