[Python-3000] removing exception .args (original) (raw)
Georg Brandl g.brandl at gmx.net
Sat Jul 21 17:08:37 CEST 2007
- Previous message: [Python-3000] removing exception .args
- Next message: [Python-3000] removing exception .args
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Andrew Dalke schrieb:
Posting here a expansion of a short discussion I had after Guido's keynote at EuroPython. In this email I propose eliminating the ".args" attribute from the Exception type. It's not useful, and supporting it correctly is complicated enough that it's often not supported correctly
In Python 2 the base Exception class works like this >>> x = Exception("spam", "was", "here") >>> x[0] 'spam' >>> x.args ('spam', 'was', 'here') >>> In Py3K the [0] index lookup disappears. This is a good thing. Positional lookup like this is rarely useful. The .args attribute remains. I don't see the need for it and propose that it be removed in Py3K.
Hm, I always found it useful to just do
class MyCustomError(Exception): pass
and give it arbitrary arguments to it without writing init method stuff that I can access from outside.
Georg
-- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
- Previous message: [Python-3000] removing exception .args
- Next message: [Python-3000] removing exception .args
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]