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


Groups > comp.lang.python > #63402

Re: the Gravity of Python 2

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; '(b)': 0.07; 'currently,': 0.09; 'objects,': 0.09; 'parameter': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '__future__': 0.16; 'defined,': 0.16; 'directive': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'operator.': 0.16; 'other)': 0.16; 'wrote:': 0.18; 'module': 0.19; 'stack': 0.19; 'cc:addr:python.org': 0.22; '(a)': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'suggested': 0.26; 'header:In-Reply-To:1': 0.27; '(c)': 0.29; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; 'bunch': 0.31; 'class': 0.32; 'running': 0.33; 'cases': 0.33; 'skip:_ 10': 0.34; 'maybe': 0.34; 'subject:the': 0.34; 'something': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'in.': 0.36; 'skip:o 20': 0.38; 'pm,': 0.38; 'problems.': 0.60; "you're": 0.61; 'places': 0.64; 'different': 0.65; 'determine': 0.67; 'do:': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=60EPRrFOq6/7FTnITKbJ2IZPAML96J+p/ZomjqbMsAs=; b=ZquVtleNElip/WyUBoeddQW2gRVotmmWGvs1AFaex5sPTvVN4tR13NOcc1KUB6EfoM ylgYdMUbj3T6y0nJm5b+hS2bBY/NmkitCrSkQsbQz/kVitPneS01xAgDX9h86aDM04rk aD+k4apkn95Np43Bqk5im3Di4H3rk4HfWKEzThKIYBK9eu47GVerYpID7BVlMKzPbLeA ixlW6/0bNTOk3mXZZXU8h9qk286PCgJhNgiEHFbM2Z4vB/jL/F2P57xCIuDNlmefbIXW /lEM5awfmkZEgQpRnRKYkVIsAPjaikthDi0ZM/JVJoZAoXBiDsibsAS7l5h0A9yy5IQQ GiDw==
MIME-Version 1.0
X-Received by 10.68.247.6 with SMTP id ya6mr125165714pbc.45.1389061719995; Mon, 06 Jan 2014 18:28:39 -0800 (PST)
In-Reply-To <CABicbJ+dG4Adgeb0RKydXWJrwYNC=HHdsWhd+X=YZ37jm+1t8w@mail.gmail.com>
References <laf00q$10k$1@ger.gmane.org> <CAPTjJmqzc2AQJ6TrBtCFnT+NBp8uYWMxMhtGNpLr+NGyhoxO-g@mail.gmail.com> <CABicbJ+k9Yim879QaDtty_dNvpZMgKA8W-zX6Xcsc5BQcnaCaQ@mail.gmail.com> <CAPTjJmozt8XcWrW2xAX7oeHDQHcDDWkoY7kMK0YXdYU+z+cOfQ@mail.gmail.com> <CABicbJ+YMRLHqQQ3nFLeqqxnvqRLRioZc9X3pZUMfZWzgEbMSw@mail.gmail.com> <CAPTjJmojtgi=fjMrZ2dW-dXpoAMWrwww-yp4BTvUtL8iNdAbBQ@mail.gmail.com> <CABicbJ+dG4Adgeb0RKydXWJrwYNC=HHdsWhd+X=YZ37jm+1t8w@mail.gmail.com>
Date Tue, 7 Jan 2014 13:28:39 +1100
Subject Re: the Gravity of Python 2
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5111.1389061729.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389061729 news.xs4all.nl 2881 [2001:888:2000:d::a6]:42004
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63402

Show key headers only | View raw


On Tue, Jan 7, 2014 at 1:15 PM, Devin Jeanpierre <jeanpierreda@gmail.com> wrote:
> The other alternative is having + (etc.) do something different
> depending on what module it's in. It's not hard to do: add a condition
> to all places where Python automatically converts, and check the call
> stack to see what module you're in.

Currently, there are __add__ methods (and __radd__ but let's focus on
__add__) on a bunch of objects, which determine what happens when you
use the + operator.

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 +?

This is why I think it's getting magical. 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.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: the Gravity of Python 2 Chris Angelico <rosuav@gmail.com> - 2014-01-07 13:28 +1100

csiph-web