Tuple Unpacking in raise

Konstantin Veretennicov kveretennicov at gmail.com
Tue Jun 21 03:02:44 CEST 2005

On 6/21/05, Steven Bethard <steven.bethard at gmail.com> wrote:
> James Stroud wrote:
> P.S. If you insist on using the two argument version of raise, you can
> do it like this:
> py> class E(Exception):
> ...     def __init__(self, atup):
> ...         Exception.__init__(self, "Error with %s-%s" % atup)
> But that seems a lot less elegant than simply using the one argument
> version.

Another workaround would be to use __init__(self, *atup), but raising
an explicitly constructed exception is preferable (IMO).

- kv

More information about the Python-list mailing list