
April 7, 2011
11:48 a.m.
On Thu, Apr 7, 2011 at 7:17 PM, Antoine Pitrou <solipsis@pitrou.net> wrote:
Perhaps the IOError constructor could be made to switch the class of the generated object based on the errno attribute passed to the constructor.
Nice suggestion. I'll try to see if that is possible.
It should be possible with appropriate fancy footwork in __new__. You do need to be careful to avoid calling __init__ on the created object twice. I know I've read an example that demonstrates the principle, but I unfortunately don't remember where (I initially thought it was in Guido's new-style class essay, but I checked and that wasn't it) Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia