[Python-3000] removing exception .args
Nick Coghlan
ncoghlan at gmail.com
Sun Jul 22 05:26:11 CEST 2007
Greg Ewing wrote:
> Nick Coghlan wrote:
>> Putting the essential parts in
>> __new__ means never having to include the instruction that "you must
>> call this classes __init__ method when subclassing and overriding
>> __init__" into any API documentation I write.
>
> I always assume that I *do* have to call the base __init__
> if I override it, unless something explicitly says that
> I don't. And I assume other people follow the same rule,
> so I don't feel obliged to spell it out when I document
> my own classes.
Andrew actually pointed out a flaw in my suggestion - if the person
subclassing wants to change the constructor signature, they end up
needing to override both __new__ and__init__, rather than just __init__.
So the implementation trick is exposed more than I thought, and the idea
is far less useful outside of tightly controlled class hierarchies
(which is where I've personally used it).
/end
tangent-that-I'd-regret-bringing-up-except-for-the-fact-that-I-learnt-something
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list