exception message output problem

Russ P. Russ.Paielli at gmail.com
Fri Dec 21 14:57:55 EST 2007


I am baffled about why my exception messages are not displaying
properly.

I have a class that represents physical scalars with units. If I type

>>> 3 * s + 4 * m

I should get something like this:

scalar.InconsistentUnits: 3 s, 4 m

to show that seconds cannot be added to meters.  Instead, the message
is broken up into individual characters, like this:

scalar.InconsistentUnits: ('3', ' ', 's', ',', ' ', '4', ' ', 'm')

This worked correctly for months, so I don't understand what went
wrong. I am using version 2.5.1 on a Dell workstation with Red Hat
Enterprise WS Linux.

As far as I can tell, I am doing everything "by the book." Here is my
exception class:

    class InconsistentUnits(Exception):
        def __init__(self, args=""): self.args = args

and here is my instantiation of it:

        raise scalar.InconsistentUnits, str(self) + ", " + str(other)

I've tried various little changes, but nothing seems to make any
difference. Has anyone else noticed this sort of behavior? Thanks.

By the way, my scalar class is available for free from http://RussP.us/scalar.htm
. A complete user guide is available. Check it out. I think you'll
like it.




More information about the Python-list mailing list