Alan G Isaac wrote:
George Brandl explained it to me this way:
It's probably best explained with a bit of code:
>>> class C(object):
... def __str__(self): return '[str]'
... def __unicode__(self): return '[unicode]'
...
>>> "%s %s" % ('foo', C()
On 9/11/2009 9:42 PM, Steven D'Aprano wrote:
However, I must admit I'm perplexed why the original example is calling
__unicode__() in the first place! Given the line:
raise self.severe('Problems with "%s" directive path:\n%s: %s.'
% (self.name, error.__class__.__name__, error))
it looks to
2009/9/12 Steven D'Aprano :
> On Fri, 11 Sep 2009 15:19:05 -0700, Chris Rebert wrote:
>
>> Sounds like IOError or one of its ancestors defines both __str__() and
>> __unicode__ () special methods but has them produce different output.
>
>
> That's what it looks like to me too, which I wouldn't call
On Fri, 11 Sep 2009 15:19:05 -0700, Chris Rebert wrote:
> On Fri, Sep 11, 2009 at 3:12 PM, Alan G Isaac
> wrote:
>> Michael Foord came up with a much simpler illustration. With Python
>> 2.6::
[snip]
> Sounds like IOError or one of its ancestors defines both __str__() and
> __unicode__ () spec
On Fri, Sep 11, 2009 at 3:12 PM, Alan G Isaac wrote:
> Michael Foord came up with a much simpler
> illustration. With Python 2.6::
>
> >>> try:
> ... open('flooble')
> ... except Exception as e:
> ... pass
> ...
> >>> e
> IOError(2, 'No such file
Michael Foord came up with a much simpler
illustration. With Python 2.6::
>>> try:
... open('flooble')
... except Exception as e:
... pass
...
>>> e
IOError(2, 'No such file or directory')
>>> unicode(e)
u"(2, 'No such fil
MYSTERY: how can "%s"%error be different from "%s"%str(error) in Python 2.6?
APOLOGY: I tried to strip this down, but could not find a simple way to
reproduce the problem. This way works, however. (There is a discussion on
the docutils-develop list.) Although there are several steps, we are ta