Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63407 > unrolled thread

Re: the Gravity of Python 2

Started byDevin Jeanpierre <jeanpierreda@gmail.com>
First post2014-01-06 19:12 -0800
Last post2014-01-06 19:12 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: the Gravity of Python 2 Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-06 19:12 -0800

#63407 — Re: the Gravity of Python 2

FromDevin Jeanpierre <jeanpierreda@gmail.com>
Date2014-01-06 19:12 -0800
SubjectRe: the Gravity of Python 2
Message-ID<mailman.5116.1389064367.18130.python-list@python.org>
On Mon, Jan 6, 2014 at 6:28 PM, Chris Angelico <rosuav@gmail.com> wrote:
> class Foo(str):
>     def __add__(self, other):
>         if isinstance(other, unicode): return self + other.encode("cp500")
>         return str.__add__(self, other)
>
> What happens if you have the __future__ directive disabling
> autoencoding on (a) the module in which this class is defined, (b) the
> one in which the it was instantiated, (c) the one that actually uses
> the +?

In both methods I described, all uses of instances of the class are
changed, but only in case A. That's a really good point, I hadn't
considered that the second case could be converted into the first.

> This is why I think it's getting magical.

Yes, it's magical, but to be fair that's stack inspection as it always is.

I am OK with a little ugliness if it makes actual work easier.

> Far better to do this sort
> of change on a per-application basis - maybe with a warning parameter
> that you can enable when running your test suite, as has been
> suggested (and in many cases implemented) for other 2-vs-3 problems.

Doing a flag like that that enables a backwards incompatible change
does in fact address that issue you were worried about originally, so
that's something. And feature-by-feature moves are, like the OP said,
still lower cost than a wholesale move.

In the end a gradual transition can still be done with the polyglot
approach, but I'm not happy that there's no way to enforce/test a
polyglot conversion until it is complete. Any kind of granularity
would have helped. :(

-- Devin

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web