Visco Shaun wrote: > Hi all > > For an exception defined as below > > class OptionError(Exception): > def __init__(self, args): > self.args = args
This should read: def __init__(self, *args): self.args = args (notice the * !) self.args holds the constructor argument tuple or list, not a single value. > def __str__(self): > return repr(self.v) > > an iteration is happening when the exception is raised > > Meanwhile for almost the same structured exception replacing the > attribute 'args' with say 'value' it is not a probs. > > class OptionError(Exception): > def __init__(self, args): > self.value = args > def __str__(self): > return repr(self.value) > > This was frustrating because for a st. OptionError('Error') for > exception 1 output will be > > OptionError: ('E', 'r', 'r', 'o', 'r') > > Meanwhile for exception 2 output will be > > OptionError: 'Error' > > which is desired..Why this behaviour? -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Sep 29 2009) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- http://mail.python.org/mailman/listinfo/python-list