Features Download
From: Meir Kriheli <mkriheli <at> gmail.com>
Subject: Re: Idea
Newsgroups: gmane.comp.python.israel
Date: Sunday 6th November 2011 08:38:54 UTC (over 6 years ago)

On Wed, Nov 2, 2011 at 5:48 PM, Ram Rachum  wrote:

> I think that your criticism applies only to print statements which have a
> comma in them, and I think these are the minority.
For me the problem is that it alters the data passed to print, which is
undesired (for example print can be overriden in 3, and that may lead to
unexpected behavior).

Plus the parenthesis is a minor one for me, and won't contribute much to
the move to python 3, there are larger fish to fry (Unicode/Bytes, absolute
imports), and handling them is part of my preferred strategy for 2 to 3
(see next section).

As far as I know the `2to3` tool doesn't produce code that's
> backwards-compatible with Python 2.
And it doesn't have to. My preferred strategy for 2 and 3 is not making
sure the same code base works with both branches - difficult and error
prone and undesirable (later down the road one will be left with cruft to
clean up).

A better one is to make sure your code passes 2to3, and during build
process, if it's python 3, run 2to3 with distribute:


> But if `2to3` can be used, this is great. The main thing here is getting
> it to create pull requests in GitHub.
IMO pull requests for such a minor issue which won't help much with 3
compat is more of an annoyance than a blessing.

Meir Kriheli

> On Wed, Nov 2, 2011 at 5:23 PM, Meir Kriheli  wrote:
>> On Wed, Nov 2, 2011 at 4:51 PM, Ram Rachum  wrote:
>>> Hey guys,
>>> Just a little idea I wanted to share.
>>> A few days ago I was looking at this GitHub repo:
>>> https://github.com/braintree/braintree_python
>>> And noticed that in their readme, they use the `print` keyword without
>>> parentheses, like this:
>>>     print "Error processing transaction:"
>>>     print "  code: " + result.transaction.processor_response_code
>>>     print "  text: " + result.transaction.processor_response_text
>>> As you know, it's always better to have parentheses around the quotes
>>> since that works on both Python 2 and 3. Not using the parentheses just
>>> serves to further delay the process of getting all Python programmers
>>> adapt to Python 3, and therefore delays the adoption of Python 3.
>>> So I thought, I could clone the repo, fix the parentheses, and send
>>> a pull request. And then comes my idea: We can write a script that goes
>>> over all public GitHub repos, and does this process automatically, and
>>> sends a pull request. We can possibly do this for a few more best
>>> except the print function.
>>> We could let a human quickly review each case to avoid bugs that would
>>> needlessly annoy people on GitHub.
>>> I think this has the potential of making a big contribution to Python 3
>>> adoption.
>>> Myself, I don't have time to work on a project like that now, but I
>>> wanted to share the idea. If someone would work on that, that would be
>>> awesome.
>>> --
>> Don't think it wold be wise as It's actually not the same in python 2
>> and  3, since the parenthesis in python 2 means treating it as a tuple
>> not params (as print is not a function). e.g:
>> With python 2:
>> Python 2.7.2 (default, Jun 29 2011, 11:17:09)
>> [GCC 4.6.1] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> print "Hello", "world"
>> Hello world
>> >>> print("Hello", "World")
>> ('Hello', 'World')
>> With python 3:
>> Python 3.2.2 (default, Sep  5 2011, 04:33:58)
>> [GCC 4.6.1 20110819 (prerelease)] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> print("hello", "world")
>> hello world
>> One has to use another pair of parenthesis for tuple:
>> >>> print(("hello", "world"))
>> ('hello', 'world')
>> Anyway, the 2to3 tool can handle it (and much more).
>> Cheers
>> --
>> Meir Kriheli
>> http://meirkriheli.com
> _______________________________________________
> Python-il mailing list
> [email protected]
> http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il
CD: 3ms