[Python-il] Idea

Ram Rachum ram at rachum.com
Wed Nov 2 17:48:23 IST 2011


I think that your criticism applies only to print statements which have a
comma in them, and I think these are the minority.

As far as I know the `2to3` tool doesn't produce code that's
backwards-compatible with Python 2.

But if `2to3` can be used, this is great. The main thing here is getting it
to create pull requests in GitHub.

On Wed, Nov 2, 2011 at 5:23 PM, Meir Kriheli <mkriheli at gmail.com> wrote:

> On Wed, Nov 2, 2011 at 4:51 PM, Ram Rachum <ram at rachum.com> 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 to
>> 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 them
>> 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 practices
>> 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 and 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://hamakor.org.il/pipermail/python-il/attachments/20111102/dbb4ad03/attachment.htm>


More information about the Python-il mailing list