News for hackers. Stuff that matters.
Re:Python 2.x vs. 3.x use survey by agentultra on Wednesday December 10, 2014 @01:39PM (#8730830)
I write all of my side projects in Python 3.4. I only write 2.7 because I work on Openstack at my day job. I avoid the use of Python 2 in every situation I can.

Python 3 has better modules built-in; the existing modules have been cleaned up; a cleaned up language (no more xrange, lazy map/filter/reduce, explicit byte-stream encoding); an improved language (sub-generators); optional type annotations; configurable allocators (in Cpython).

I just prefer it to Python 2 these days.

edit: And all of the upstream effort into making the language better is going into Python 3.

Re:Python 2.x vs. 3.x use survey by merlincorey on Wednesday December 10, 2014 @01:59PM (#8730938)
As one of those crazy functional programmers who uses python, can you please explain to me what the benefit is in remove xrange, lazy map/filter/reduce, and other functional mainstays in exchange for what is essentially more syntax to do the same?
Re:Python 2.x vs. 3.x use survey by maxerickson on Wednesday December 10, 2014 @02:05PM (#8730979)
It's the other way around, they are not removed, the default implementations are now lazy. So in python 3 you get an interator:

   >>> map(lambda i:i*i, range(5))
   <map object at 0x010622F0>
and have to explicitly construct a list:

    >>> list(map(lambda i:i*i, range(5)))
    [0, 1, 4, 9, 16]
    >>>
Re:Python 2.x vs. 3.x use survey by merlincorey on Wednesday December 10, 2014 @02:43PM (#8731231)
Ah, I actually like that!

That is indeed cleaner. Thanks for the explanation.

Re:Python 2.x vs. 3.x use survey by agentultra on Wednesday December 10, 2014 @03:20PM (#8731429)
Traversing a binary tree without an explicit stack is also much cleaner thanks to sub-generators.

    if tree.left:
        yield from traverse(tree.left)
    
    yield tree
    
    if tree.right:
        yield from traverse(tree.right)
As a trivial example.
Re:Python 2.x vs. 3.x use survey by bachmann1234 on Wednesday December 10, 2014 @02:02PM (#8730968)
well, range in python 3 is lazy. They replaced the non lazy implementation with xranges impl.

Same applies to map, filter and I believe reduce as well.

Re:Python 2.x vs. 3.x use survey by aikah on Wednesday December 10, 2014 @02:15PM (#8731050)
> I write all of my side projects in Python 3.4. I only write 2.7 because I work on Openstack at my day job.

And that's the issue.You cant be a pro pythonist unless you know both,even if you prefer 3.x .Not saying 2.x is an entire different language.Still,Python devs have to know the differences between both versions.

Re:Python 2.x vs. 3.x use survey by kragniz on Wednesday December 10, 2014 @02:16PM (#8731059)
Let's just be thankful for OpenStack dropping support of Python 2.6!
Re:Python 2.x vs. 3.x use survey by acveilleux on Wednesday December 10, 2014 @05:07PM (#8732027)
Something I can't wait for my day job to do. At least we mostly stopped using 2.3...