different behaviour for user defined exception with attribute args
Dave Angel
davea at ieee.org
Tue Sep 29 17:20:22 EDT 2009
Visco Shaun wrote:
> Hi all
>
> For an exception defined as below
>
> class OptionError(Exception):
> def __init__(self, args):
> self.args = args
> def __str__(self):
> return repr(self.v)
>
> an iteration is happening when the exception is raised
>
> <snip>
>
>
What is self.v intended to produce? Perhaps you meant self.args ??
That doesn't explain your error though. I suspect you didn't quote your
code accurately.
The other problem is that args is intended to be a tuple. So you want
to use *args for your formal parameter.
DaveA
More information about the Python-list
mailing list