[Python-ideas] duck typing for io write methods
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Thu Jun 13 15:09:30 CEST 2013
Nick Coghlan <ncoghlan at ...> writes:
>
> On 13 June 2013 22:46, Wolfgang Maier
> <wolfgang.maier at ...> wrote:
> > ok, that's a nice technical explanation, but is that reasonable behavior?
> > Shouldn't Python check first to see if the object defines __bytes__() before
> > defaulting to the other options?
>
> It doesn't matter whether it's reasonable at this point, it can't be
> changed without breaking backwards compatibility. Those things are
> special cased, and it's not worth the hassle of changing it.
>
> Cheers,
> Nick.
>
I'm confused. Why would it break backwards compatibility, when the default
behaviour is the same? As far as I can see, it would only affect code that
defines a __bytes__ method for subclasses of str or int, but then relies on
them never actually getting called ??
Best,
Wolfgang
More information about the Python-ideas
mailing list