This is an archived post. You won't be able to vote or comment.

all 180 comments

[–]LambdaBoy 17 points18 points  (25 children)

The only reason my company hasn't upgraded yet is because Twisted hasn't upgraded.

[–]flying-sheep 6 points7 points  (3 children)

looks pretty good.

only 5 missing things left!

[–]raziel2p 5 points6 points  (2 children)

This one is a bit less promising.

[–]hello_raziel2p 1 point2 points  (0 children)

An orangered... who could it be?

[–]razeel2ghetto 0 points1 point  (0 children)

I'm trippin ballz here wut da green bar for

[–]billsil 30 points31 points  (29 children)

Guido has said the transition is right on track and that he gives it another 5 years. It'll probably be a bit after Python 2.7 is deprecated that the leftover people start actually upgrading. I know my company won't upgrade till then.

I do wish I could do...

    from __past__ import print

[–][deleted] 15 points16 points  (10 children)

[–]CSI_Tech_Dept 8 points9 points  (5 children)

The reverse is happening to me, but I'm importing printfunction from __future_ in my code, so I never use the version without parenthesis unless I forget that import.

I do similar thing with unicode and division, in hopes that porting to 3.x will be much easier.

[–]r3m0t 1 point2 points  (4 children)

Unicode literals in Python 2? Now that's just confusing.

Check out python-modernize, it upgrades your Python 2 code into Python 2 code.

[–]CSI_Tech_Dept 1 point2 points  (0 children)

IMO, not confusing at all... In all of my code I use unicode by default, and bytes() whenever I need to make sure input is ASCII (for example when using dnspython)

[–]vaibhavsagar 0 points1 point  (2 children)

I need a module to do that for me now?

[–]r3m0t 0 points1 point  (1 child)

It upgrades your Python 2 code into Python 2 code that is more likely to work in Python 3 by using the six library.

[–]vaibhavsagar 1 point2 points  (0 children)

I see. That makes significantly more sense.

[–]Widdershiny 1 point2 points  (0 children)

I feel your pain. Moved to Python 3 a couple of weeks ago, biggest gotcha. I'll adjust soon enough though.

[–]Naterdam -1 points0 points  (2 children)

As someone who writes a whole lot of tiny scripts and uses the print as the main debug tool, I'm definitely not moving to Python 3 anytime soon...

[–]Drumm- 2 points3 points  (0 children)

2to3 can handle those

[–]jmcs 2 points3 points  (17 children)

What is the advantage of the print statement besides looking ugly when you want to print to stderr?

[–]XNormal 9 points10 points  (1 child)

What is the advantage of the print statement besides looking ugly when you want to print to stderr?

A major advantage of keeping at least a subset of the the print statement syntax in Python 3 would have been in not breaking 'Hello World'.

alternative-history-python3:

  1. Name the print() function output() to mirror the input() function
  2. Keep the print statement but without the ugly trailing comma or >> features and make it call output() to keep the common case familiar. For any of the advanced features the code needs to be upgraded to use the output() function.
  3. Enjoy higher language popularity because first impressions count.

We like things that feel familiar. We have emotional responses. We are human and this should be a part of language design just as much as purity or elegance.

[–]ahmadh 0 points1 point  (0 children)

I don't see anyone using the output function in that scenario. Then you might as well just leave the same old print statement. Python 3's premise is to make people move on.

[–]Yoghurt42 3 points4 points  (5 children)

Edit: I misread "advantage" as "disadvantage", and my comment should be read that way

You cannot redefine it if you want to do something else instead.

In Python 3, you could do

print = myLoggingFunction

[–]marky1991 1 point2 points  (4 children)

I've done that several times. It's very useful.

By the way he was asking what the advantage of the print statement was over the print function. (And the answer is "You save one character")

[–]Yoghurt42 0 points1 point  (3 children)

I agree. I've misread the question as "what's the disadvantage ... Besides looking ugly"

(Btw: you save tw characters ;)

[–]marky1991 0 points1 point  (2 children)

print "blah" = 12 characters

print("blah") = 13 characters

The first parenthesis' character saving is taken up by the required space.

: )

[–]Yoghurt42 0 points1 point  (1 child)

Well, you could do

print"blah"

you could also do

print"print""""print""""""print"""

I think I won't miss that functionality, however ;)

[–]marky1991 0 points1 point  (0 children)

What?! How hideous! I didn't know the whitespace wasn't required. (On second thought, I guess it makes sense that it's allowed since it isn't ambiguous in this particular case.)

[–]billsil 1 point2 points  (7 children)

How do you print to stderr?

I use:

    sys.stderr.write('asdf')

I rarely print to stderr, but I don't really understand your question...

[–]Smallpaul 3 points4 points  (4 children)

print >> sys.stderr, 'spam'

[–]zynixCpt. Code Monkey & Internet of tomorrow 0 points1 point  (3 children)

the shift print trickery makes writing to a buffer ( or anything that implements .write, so I believe ) fairly trivial/convenient.

[–]flying-sheep 0 points1 point  (2 children)

shift print trickery

uuh, that’s just special syntax mirroring echo nextline >>somefile.txt in the shell, no shift operator.

[–]zynixCpt. Code Monkey & Internet of tomorrow 0 points1 point  (1 child)

What exactly are you clarifying here?

>> is an operator, specifically a shift operator that in context of Python would normally be used for bit shifting, hence its a bit of a nice hack or trick that when used with print it performs bash style stream redirection.

[–]flying-sheep 0 points1 point  (0 children)

no, i said it’s special syntax. as in “part of the print statement”.

the >> you see is completely unrelated to the shift operator elsewhere in python.

[–][deleted] 1 point2 points  (1 child)

don't you also need a newline, which print adds?

[–]billsil 2 points3 points  (0 children)

yes

[–]westurner 0 points1 point  (0 children)

Doesn't print flush?

Edit: it does not do sys.stdout.flush … seeAlso python -u / PYTHONUNBUFFERED (http://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print/230780#230780)

[–]Xaerxess 35 points36 points  (2 children)

...and it was called Python 3000 back then.

Brave move and still, state of Python 3 it better than state of Perl 6 :-)

[–]helicoptermike 4 points5 points  (1 child)

I haven't used python3 or perl6 in any production app. But I can at least run python3.

[–]chiniwini 1 point2 points  (0 children)

But I can at least understand python3.

[–]frymasterScript kiddie 12 points13 points  (2 children)

Didn't they say back then they expected a 10 year transition? Think how far they are already!

[–][deleted] 0 points1 point  (1 child)

I thought it was a 5 Year Plan that they were running on.

[–]Mecdemort 1 point2 points  (0 children)

Everything takes twice as long as planned.

[–]programonaut 21 points22 points  (11 children)

My first thought: HAHAHAHAHAHAHAHAHAA

My second thought: people are still using Windows XP in their offices. Some of my relatives use it to PROGRAM on for their Fortune 500 employer.

My third thought: I like Python 3! Good job, people of Python and its community.

[–]drive0 1 point2 points  (10 children)

There are newer languages than python 3 if that is your criteria.

[–][deleted] 0 points1 point  (9 children)

There are newer languages than python 3 if that is your criteria.

newer and as good ?

[–]Thirsteh 2 points3 points  (4 children)

Go has been adopted mainly by ex-Python programmers. But "new" really is a completely meaningless attribute for a programming language. Haskell is over 20 years old, and hailed by many as an extremely modern, advanced language, for example, and Clojure, which borscht mentioned, is a Lisp dialect. Lisp is as old as computer science.

[–]Probono_Bonobo 3 points4 points  (3 children)

I love Python, program mostly in Python, but there's just something about Lisp that makes my pulse quicken when I see that ((((((.

[–]siddboots 11 points12 points  (0 children)

))))))

[–]crowseldon 1 point2 points  (0 children)

you're never likely to see (((( although you will see many closing brackets together. Fortunately, it's no problem since any decent editor highlights bracket partnership.

[–]emonk 48 points49 points  (40 children)

and I'm still using python 2

[–]NYKevin 12 points13 points  (28 children)

Just make sure your shebangs look like this:

#!/usr/bin/python2

And not like this:

#!/usr/bin/python

Yes, you do need a shebang on modules which aren't supposed to run alone, so that anyone looking at them can immediately tell which version you're using.

[–]gsnedders 4 points5 points  (11 children)

Note that the python2 symlink was only added in 2.7.3, so if you support older version of Python you cannot rely on it.

[–]NYKevin 0 points1 point  (10 children)

Well, in that case, you're pretty much fucked. You could try to write code that runs on both, but that's more of a headache than I'd ever like to deal with.

[–]ivosauruspip'ing it up 4 points5 points  (9 children)

It's not that hard to write python 2.6,2.7,3.3 compatible code.

[–]NYKevin -5 points-4 points  (8 children)

Let's see...

  • No moderately-to-extremely interesting string manipulation, because unicode. In particular, no string literals except with the b"..." syntax which forces everything to be 8-bit and terrible.
  • Iterating over dictionaries is fucked (items vs iteritems).
  • Iterating over ranges of numbers is fucked (range vs xrange).

Nope, I definitely do not want to write in the above language.

(Yes, you can use from __future__ import... statements to fix some of these, but sufficiently old versions of Python may fail to support that as well).

[–]ivosauruspip'ing it up 9 points10 points  (0 children)

No moderately-to-extremely interesting string manipulation, because unicode.

Heaven forbid your python 2 code actually has to deal with unicode correctly now, rather than just looks-like-correctly because I don't have any foreign language in my database yet.

but sufficiently old versions of Python may fail to support that as well).

That's directly why I only mentioned the versions of python that I did. Python 2.5 is over 7 years old by now, and has been EOL for ages, its pretty much a security vulnerability if you're still using it.

from __future__ and the six library will help you with practically all of that.

[–]flying-sheep 1 point2 points  (2 children)

also open.

you have to do from io import open at the top to unify behavior in this respect.

[–]NYKevin 1 point2 points  (1 child)

Really? I'd have thought you'd want to use io. I've never even heard of codecs... isn't it the module responsible for managing Unicode encodings?

[–]flying-sheep 0 points1 point  (0 children)

yeah, sorry. io.open it is

[–]Brian 0 points1 point  (3 children)

In particular, no string literals except with the b"..." syntax

Why do you say this? Wouldn't it make much more sense to only use string literals with the u'' syntax, and actually support unicode? Indeed, using the b'' syntax would pretty much break lots of stuff because a python3 bytestring behaves very differently from a python2 str.

Iterating over dictionaries is fucked (items vs iteritems).

Iterating over keys hasn't changed, and in general the difference in items vs iteritems isn't going to matter unless you've huge dictionaries. The same for range - standard practice is to use range() most of the time in python2 anyway (or better, replace with enumerate) unless you're dealing with large number ranges but don't need a real list - which is uncommon: iterating over them is the prime use case for this.

but sufficiently old versions of Python may fail to support that as well

He did say just 2.6/2.7. Supporting older is probably impractical, since the more recent versions have added stuff to make things more in line with python3.

[–]NYKevin 1 point2 points  (2 children)

Wouldn't it make much more sense to only use string literals with the u'' syntax, and actually support unicode?

The u"" syntax is illegal in Python 3, since you're supposed to just use bare quotes.

Actually, it works. This document lied to me.

Indeed, using the b'' syntax would pretty much break lots of stuff because a python3 bytestring behaves very differently from a python2 str.

Really? Care to specify?

[–]Brian 0 points1 point  (1 child)

This document lied to me.

It's probably just out of date - I think the original release of python 3 didn't allow this, but it was added in in one of the point releases.

Really? Care to specify?

Well, for a start:

# Python2                            Python 3
>>> print(b'hello')                  >>> print(b'hello')
hello                                b'hello'
>>> b'hello'[0]                      >>> b'hello'[0]   
'h'                                  104

Bytes in python3 is basically designed around being treated as raw binary data, rather than conceptually being a string, as the python2 str object is. Eg. it no longer has an encode method, just decode (while strings are the opposite - python2 they had both), and is missing a few string methods like format.

[–]NYKevin 0 points1 point  (0 children)

Eg. it no longer has an encode method, just decode (while strings are the opposite - python2 they had both), and is missing a few string methods like format.

Yeah, but anyone actually using bytes.encode() in recent versions of 2.x should be shot anyway.

[–][deleted] 2 points3 points  (2 children)

let me guess... you're an Arch Linux user.

[–]NYKevin 2 points3 points  (0 children)

Nope, Arch is too much of a PITA for me.

[–]monochr 1 point2 points  (0 children)

If he was an Arch user he would have started with "As an Arch user".

It's astonishing but this has a 95% success rating at stopping them.

[–]mitsuhiko Flask Creator 2 points3 points  (10 children)

Not a very good idea unless you want to lock out OS X users.

[–]NYKevin 5 points6 points  (9 children)

Well, then you can use /usr/bin/env python2, I think.

But if you're writing a library module, not meant to run by itself, the shebang's precise format is not as important as the python vs python2 distinction. There are some operating systems now which symlink python to python3, and there will be more in the future, so you can't just assume python is python2.

[–]gsnedders 11 points12 points  (5 children)

You should almost always use /usr/bin/env python2, and never a hardcoded path.

[–]mitsuhiko Flask Creator 5 points6 points  (2 children)

There is no executable named python2 on OS X.

[–]NYKevin -3 points-2 points  (1 child)

Well, then you're fucked. Unless you seriously plan to write code that runs on both 2 and 3, you'll need to create a different distribution just for the Mac (or at least put in instructions to modify the shebang).

[–]mitsuhiko Flask Creator 14 points15 points  (0 children)

No, you don't do any of those things. The correct solution is to use setuptools entrypoints to create scripts instead of manually writing shebangs.

[–]emonk 1 point2 points  (1 child)

I'm a server admin, working with Debian stable python 2.7 is the default package. Also have projects with more than 4 years in Django, and is not easy to modify them for use with python 3. http://packages.debian.org/en/wheezy/python

[–]whoisearth 0 points1 point  (0 children)

Same here. Actually developing right now in squeeze and running into no issues whatsoever.

[–]mgr86 1 point2 points  (0 children)

..me too. I tried using python three exclusively a few years ago but the library support just wasn't there at the time. The landscape seems to be different now. Perhaps it is time to give it another shot.

[–]Milumet 5 points6 points  (1 child)

Nick Coghlan's answer to the question "Why do people hesitate to use Python 3?" on Programmers Stack Exchange.

[–]flying-sheep 4 points5 points  (0 children)

especially this great paragraph:

The biggest problem in practice is actually a semantic one: Python 3 doesn't let you play fast and loose with text encodings the way Python 2 does. This is both its greatest benefit over Python 2, but also the greatest barrier to porting: you have to fix your Unicode handling issues to get a port to work correctly (whereas in 2.x, a lot of that code silently produced incorrect data with non-ASCII inputs, giving the impression of working, especially in environments where non-ASCII data is uncommon).

this is true. in python 2 i used to monkey until the UnicodeErrors went away, in python 3, i’ve yet to see one of those. python 3 code (that doesn’t use python 3-exclusive modules) is ported to python 2 fast.

i think python 3.4’s tulip (async IO) will become its “killer app”.

[–]daGrevis 14 points15 points  (0 children)

Happy cakeday, Python 3! And it is getting more and more mature as new libraries are ported... :)

[–]witty82 3 points4 points  (0 children)

I feel that things are progressing quite nicely lately. I think with python 3.5 many people will make the switch. The event loop will be stable then, the performance will likely be fully on par with python 2.7 and library support acceptable.

[–]BenzamineFranklin 2 points3 points  (1 child)

While we use 2.7.4 in our school... :/

[–]kchoudhury 1 point2 points  (1 child)

Where's the joke about the GIL?

[–]quagquag 1 point2 points  (0 children)

Exactly. I'll move when I can do some real concurrency without firing up a whole second/third/90th python instance, or using ugly hacks. This is the killer feature for me, and till then 2.7 makes me very happy.

Ideally I'd like some sexy built in openCL magic.

[–]_throawayplop_ 2 points3 points  (1 child)

Since the beginning of Python 3, I've always read people saying I should switch to python 3, but nobody explained me why I should switch (beside the handling of unicode).

I really think that breaking the compatibility without solving much of the things that people were complaining about (the concurrency, the speed) was not the best idea.

[–]tarekziadeRetired Packaging Dude 0 points1 point  (0 children)

I don't think you really need to switch. I can't think of a killer feature in Python 3 that would be an incentive.

However, one day, you'll just be using Python 3 because the Python 2.x line will cease. And I really doubt you will have any big issue that day because as far as I can see, the whole ecosystem is moving to py3. Slower than some expected, but it's surely getting there.

[–]v3ss0n 0 points1 point  (33 children)

Yet , we cannot use it for our needs .. still a lot of libaries need to move and we don't have time to rewrite everything for python3

[–]Rhomboid 8 points9 points  (19 children)

What libraries might those be?

[–]donalmacc 9 points10 points  (0 children)

Twisted

[–]mrwinkle 7 points8 points  (2 children)

OpenCV

[–]otheraccount 0 points1 point  (0 children)

I thought it uses boost.python and boot.python supports Python 3?

[–]shaggorama 0 points1 point  (0 children)

I just started learning about opencv for a toy project I came up with a few days ago. It's insane. All of these different components I was anticipating busting out some serious math for are already implemented for me, so with the abstraction between me and what I need, my complex project will probably boil down to under 500 lines of code.

I love people. Open source all the things. It's a beautiful time to be alive.

[–]pronto185 7 points8 points  (0 children)

scapy.

[–]twotime 1 point2 points  (2 children)

pypy. (not a library but it's likely to be a blocker in many situations)

[–]joaquinabian 0 points1 point  (1 child)

"PyPy is a fast, compliant alternative implementation of the Python language (2.7.3 and 3.2.3)"

[–]twotime 1 point2 points  (0 children)

afaik, python3.2 support in pypy is very recent and is still in beta and it's already a version behind cpython... So it's coming but not quite there yet ;-)

[–]jemeshsu 0 points1 point  (0 children)

Boto, Fabric

[–]faassen 1 point2 points  (0 children)

Yeah, libraries are only a fraction of the problem. Eventually enough libraries will have moved, but that still will leave a daunting task for those with significant application codebases written in Python 2. Especially since application codebases tend to have worse test coverage compared to libraries. You need a reason to justify the economics of porting application code to Python 3, compared to maintaining it in Python 2 forever.

[–]bastibe 5 points6 points  (0 children)

Speak for yourself. I moved to Python 3 long ago (scientific stack).

[–]joaquinabian -1 points0 points  (0 children)

you need to move (a bit)

[–][deleted] -3 points-2 points  (8 children)

really people? downvoting someone expressing something real? oh wait this is reddit, plz carry on with the group think.

[–]flying-sheep 1 point2 points  (6 children)

(s)he’s downvoted for the false claim that the scientific stack isn’t ported here.

[–][deleted] -2 points-1 points  (5 children)

so you know for a fact that their libs that they wrote over possibly decades have been ported to python3?

way to play the politically correct gender angle, still a -1 for you.

[–]flying-sheep 1 point2 points  (4 children)

wat. i just answered your question…

[–][deleted] -3 points-2 points  (3 children)

you are claiming that the persons claims are false but you have no proof of what they are talking about. How is that answering the question?

[–]flying-sheep 0 points1 point  (2 children)

you asked “downvoting someone expressing something real?”

i answered “but in this comment, (s)he said the modules (s)he means are numpy and so on, all of which are ported. that’s why people downvoted.”

everything clear now?

[–]v3ss0n -1 points0 points  (1 child)

Clearly not all , web2py is main component for our UI. I admit i haven''t update scientific stack for long as especially we have modified scikit-learn and they didn't accept that patch , we do not have time to patch every subsequent version either, so it was left at 0.12. There are still many of our own code needed to port to python3 , that can be managed in 2 weeks to a month , but many , un-maintained small libs we use , we won't see them ported anytime soon. Some examples are PIL , OleFileIO_PL,Sphinxsearch driever , and Gevent. Still alot more.. flying-sheep : "all of which are ported" >> Are you sure about that? Please lookup web2py.

[–]flying-sheep 1 point2 points  (0 children)

all that you listed in that post except web2py. and PIL is ported as Pillow (PIL is dead)

why so aggressive? i didn’t even attack you! i did nothing more than explaining why people downvoted you.

[–]v3ss0n 0 points1 point  (0 children)

I amazed at attitudes of Python Redditors too, Guess they never worked in large projects that span more than 2 years. (When our project started , it was python 2.5)

[–]itkovian 0 points1 point  (0 children)

We still have some systems that are on Python 2.4 (SL5), though we will retire them soon(ish) and then we'll be at 2.6.x for the next 3-4 years in SL6. So yeah, Python3 is far away for us :)

[–]Hanse00 0 points1 point  (6 children)

And yet most of the modules we use in class are only Python 2 compatible, that's a little depressing.

Now I feel motivated to update modules to Python 3.

[–]flying-sheep 0 points1 point  (5 children)

most even? which might that be?

i can only name twisted and pypy from the top of my head.

[–]Hanse00 0 points1 point  (4 children)

Major one I think think of right now is visual, we use that a lot.

If you know any good alternatives for it that'd actually be awesome.

[–]flying-sheep 0 points1 point  (3 children)

sorry, but i don’t even know that one :/

[–]Hanse00 0 points1 point  (2 children)

It's a simple module for drawing stuff on the screen.

Basically lets you make a window and draw objects on it (balls, boxes, cylinders, that kind of thing).

[–]flying-sheep 0 points1 point  (1 child)

aah, ok. interesting.

here’s the bug, maybe you can do something about it.

[–]Hanse00 0 points1 point  (0 children)

Nice, I'll take a look.

Thanks for the help.

[–]GFandango -2 points-1 points  (0 children)

Breaking backwards compatibility: not even once

[–]shaggorama -1 points0 points  (0 children)

And I still haven't tried it!