On Class namespaces, calling methods
Duncan Booth
duncan.booth at invalid.invalid
Sun Apr 11 05:24:29 EDT 2010
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> On Sat, 10 Apr 2010 16:35:29 +0000, Duncan Booth wrote:
>
>> Anyway, the moral is never, ever to use old-style classes in Python
>> 2.x. You will get weird and unexpected results.
>
> That's a bit strong. They're only weird and unexpected if you're not
> expecting them and don't understand them.
Which is exactly what will happen when some subclass tries to use a
property not realising that it is actually an old style class. That kind of
problem can be a real pain to track down.
>
> Why are we worrying about the exact error message? New style or old
> style, they both raise TypeError, and testing for the exact error
> message is a fragile, dangerous thing to do: error strings are not
> part of the Python API, and are subject to change without notice, for
> any reason. For all we know, Python runtimes compiled on a Tuesday
> could use different error messages from runtimes compiled on
> Wednesdays.
>
I'm intrigued by the exact error message because I'd like to know the
answer to one of the questions Vicente asked: what object is being passed
to 'm' on the system which complains "m() takes no arguments (1 given)"
I'm sure it must just be an insignificant difference, but I hate unanswered
questions.
More information about the Python-list
mailing list