Python 3.0 Released
licorna writes "The 3.0 version of Python (also known as Python3k and Python3000) just got released few hours ago. It's the first ever intentionally backwards-incompatible Python release."
← Back to Stories (view on slashdot.org)
Comment removed based on user account deletion
Python 3 being out is great, they've fixed a few things that allow bad programming, but does anyone know how long it will take for the libs to start getting ported? Especially numpy and scipy
previous releases were incompatibilie with earlier ones unintentinally.
The release notes might interest people:
http://docs.python.org/dev/3.0/whatsnew/3.0.html
Also note that in the end of the release notes are info on the migration path from Python 2 to 3. I'll leave the rest to people who bother to RTFA... ;)
.: Max Romantschuk
The cool thing about Python is it's "time machine". In Python 2.x you can "from __future__ import " to use features scheduled for future releases. With the release of Python 2.6 there's also a "2to3" tool that will point out revisions needed for 2.x code to be 3.0-compatible, and generate patches for you.
The Python developers have been aware of the difficult road of migration long before the release of Python 3, and they did a lot of careful planning and hard work for it. One of them being the __future__ module that has been there for quite long time just for this reason.
As a Python user, my hat off for them. I wish them success heartily.
BTW: In case you don't know, there's an Easter egg in the time machine: "from __future__ import braces" ;)
Colorless green Cthulhu waits dreaming furiously.
Sounds great! Now to wait a few weeks while smart people find and fix all the security holes, so I can go and safely get version 3.1.
Where's the mac version..?
MABASPLOOM!
Yes, Python 3.0 is a break.
But in the past and forseeable future, Python has been exceedingly helpful, much more than most languages, during upgrades.
Usually one has several months to try out new features-- they're in the current version but turned off until you ask for them with "future_builtins".
Plus there's often a backwards feature in the next version to revert back to old behavior.
Not to mention a -3 option to point out the lines in your old program that will need changing for version 3.
But sometimes the changes are so big they can't be encompassed by a compiler switch. Such it is with 3.0.
But I just came in here for an argument!
Well that's nice, any braces for blocks yet? Just kidding.
BTW, whatever happened to Ruby? It just seemed to have dropped off the map in the past 6 months or so.
Salut,
Jacques
I'm fairly certain they got all these non-backward compatibility issues out of the way with this release so they don't have to do this kind of thing again for a long while. My guess is, they wont ever put out a non-backwards compatible release, since those changes were mostly to fix poor coding practices like being able to run certain functions without braces (e.g print "hi").
MABASPLOOM!
If the syntax differences and the differences in the standard library are well-documented, shouldn't it be possible to write a program that migrates 2.x code to 3.x code automatically? Does such a program exist?
OK, never mind, I just saw it, there seems to be such a beast: http://docs.python.org/dev/3.0/library/2to3.html#to3-reference
SyntaxError: maybe in 3.5
Instead, write everything in smug.
Nerd rage is the funniest rage.
Reworked Unicode support is a big deal. It was there before, of course (unlike Ruby - meh), but all those Unicode strings vs 8-bit strings, and the associated comparison issues, complicated things overmuch. Not to mention the ugly u"" syntax for Unicode string literals which was too eerily like C++ in that respect. Good to see it move to doing things the Right Way by clearly separating strings and byte arrays, and standardizing on Unicode for the former.
Now, if only we could convince Matz that his idea for Unicode support in Ruby 2.0 - where every string is a sequence of bytes with an associated encoding, so every string in the program can have its own encoding (and two arbitrary objects of type "string" may not even be comparable as a result) - is a recipe for disaster, and take hint from Python 3...
So what are you going to do, take all your existing Python applications and rewrite them in a different language, in order to avoid the "significant amount of work to maintain existing functionality with new language version"?
AccountKiller
Besides teh above remark of well thoguth migration paths - it is importante to remakr that support for python 2.x has not ended in any way.
As far as Iam aware, the recomendation is to keep working with python 2.6 - and use the py2to3 script to regularly to make 3.0 releases if you you can (i.e. if your dependencies have 3.0 versions already).
No need to worry about anything, this will be a smooth, years long, transition. Chances are we will even see a python 2.7 before 2.x is officially deprecated.
-><- no
multiple versions of python can live happily together and will be seperatly maintained, no worries about backwards compatibility. sorry for typos ;)
Trying to install linux on my microwave, but keep getting a kernel panic...
It's also cleanup of some stupid syntax that was there for ages. For example, exception handling. Old style:
New style:
It's fairly obvious that the latter is much clearer.
As they didn't fixed the stupid forced-indentation thing.
factor 966971: 966971
First thing mentioned on the 'what's new' page (http://docs.python.org/dev/3.0/whatsnew/3.0.html)is that you'll have to change your code from
print x, y, z,
to
print(x, y, z, end="")
I can see the value of making things more consistent, but it seems to me whenever they update things in Python, it's usually to make programming in it a little bit harder.
Why not make print a function, but then change the language to not require parentheses for any function call? You'd still have to use them when calling a function with zero arguments, and in sub-expressions, but to not require parens for top-level function calls would, if nothing else, make playing around in interactive mode or with short scripts a lot more pleasant.
Granted, I come from a Ruby background, so I may not know what I'm talking about. My experience with Python is trying to write some scripts on my OLPC, where the craptacular rubber keyboard made typing parentheses all the more agonizing. I finally caved and installed Ruby so I could get some work done. Maybe people who prefer Python really like typing parens. And underscores.
Duct tape, XML, democracy: Not doing the job? Use more.
Damned straight! I can't stand all those kids and their silly computer "languages". That's why I write only UNIVAC 1100 machine code. By writing for a dead platform, I know that I will NEVER have to waste time patching my work with updates.
I'd suggest rewriting in COBOL. This would make sure that one's precious code is not going to be broken by a new incompatible release.
And if OOP is strongly desired, try Simula-67.
That'll be when Perl 6.0 ships.
AFAIK Perl 6.0 is already there, in the form of Pugs (which is said to be compatible with all the specs), and it's just the implementation of Perl 6 in perl6 itself what people are waiting for. You can go and write actual Perl 6 code, and run it on Pugs, and it'll work.
I heard they're going to use Python 3.0 for the impending from-scratch rewrite of DNF.
No you didn't.
echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
please, please, please!
Besides teh above remark of well thoguth migration paths - it is importante to remakr that support for python 2.x has not ended in any way.
As far as Iam aware, the recomendation is to keep working with python 2.6 - and use the py2to3 script to regularly to make 3.0 releases if you you can ...
Are you typing while drunk?
"I think it would be a good idea!"
Gandhi, about Internet Security
Which will also be the point of singularity
Interestingly, it IS backwards compatible in areas that you wouldn't think it should be. For instance, the following program takes the version number, adds one to it, and divides by two. You'd think it'd give a different answer between version 3 and version 2. Glad they kept this program working for me, as it's the secret production code that runs my multi-million dollar business.
import sys
version=int(sys.version[0])
print (version+1)/2
Prints 1 in either version. (on the bright side, 1/2 is now 0.5!)
oops I really screwed that joke up... crap. somebody fix it.. you know what I was trying to do!
Dang, my FIRST slashdot mistake!
GREAT!
Interestingly, it IS backwards compatible in areas that you wouldn't think it should be. For instance, the following program takes the version number, adds one to it, and divides by two. You'd think it'd give a different answer between version 3 and version 2. Glad they kept this program working for me, as it's the secret production code that runs my multi-million dollar business.
import sys
version=int(sys.version[0])
print (-version+1)/2
Prints -1 in either version. (on the bright side, 1/2 is now 0.5!)
Changelog: added two minus signs. Is that better? Am I going too far with this?
too bad it doesnt install from source out of the box, even with libgdbm-dev installed
make
running build
running build_ext
Failed to find the necessary bits to build these modules:
_dbm
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
see bug here. Why they would announce a release that wouldn't build for a major distribution such as ubuntu baffles me.
You're right that backward compatibility isn't broken hard, but it's going to be broken EVERYWHERE because they've changed the syntax for print and the semantics for list operations by moving everything to iterators.
Prints will be easy to fix, because the old style will cause syntax errors... but old-style code that assumes range() and zip() return lists will break at runtime. Bugs will turn up months after you thought you fixed some code because you forgot some corner-case that isn't called often.
(I'm not complaining - I agree with most of the changes in 3 - I'm just saying that updating code won't necessarily be trivial)
Signs of the apocalypse:
* A black man was elected President of the US - November 4, 2008
* Chinese Democracy was released - November 23, 2008
* Python 3000 is released - December 4, 2008
* ?
* ?
* Large Hadron Collider starts operations - ?
* Duke Nukem Forever is released - ?
No sig for the moment.
what's amazing is that he seemed to have sobered up in less than 3 sentences. he has one hell of a metabolism.
I think you should use a few more posts to explain the joke. The more you go on the funnier it gets. :)
Besides teh above remark of well thoguth migration paths - it is importante to remakr that support for python 2.x has not ended in any way.
As far as Iam aware, the recomendation is to keep working with python 2.6 - and use the py2to3 script to regularly to make 3.0 releases if you you can ...
Are you typing while drunk?
No, he generated that comment with Python 2.6 code but ran it with the new release.
An argument isn't just contradiction!
Yes it is.
keyword or positional?
And Rakudo, aka Perl6 on Parrot, is coming along quite nicely, as well.
I was able to install python3.0 but as usual, there is no readline support.
Has anyone been successful in getting readline to work with python3.0?
I told you once.
It's a similar decision to "should I change lanes because that other one is going faster". See the intro to 'Office Space' for the inevitable result.
In other words: if you want to minimize your exposure to backwards-incompatibility, shouldn't you just stay in the language that just got it out of the way? Of course, my logical flaw is the assumption that language migrations of this sort are uniformly distributed, in reality it's probably a function of the languages' owners.
-t.
> thoguth migration paths
Sounds like a good basis for a "Call of Cthulhu" adventure.
Perl 6 will be released (soon?)
Wish I had mod points. Thank you for a good laugh, sir.
Why not make print a function, but then change the language to not require parentheses for any function call? You'd still have to use them when calling a function with zero arguments, and in sub-expressions, but to not require parens for top-level function calls would, if nothing else, make playing around in interactive mode or with short scripts a lot more pleasant.
There's a specific problem there with Python - which is that not requiring parenthesis on a function call (but allowing them) creates an ambiguity... Is "f (x, y)" a one-argument function call (tuple of x and y) or two? This is in addition to the usual ambiguities involving nested calls and the general disparity between that form and the syntax that governs the rest of the language.
Still, Ruby does OK with that strategy, right?
My impression of Ruby so far (not having done much with it) is that it's a little more Perl-like in its treatment of syntax. Syntax isn't always consistent (for instance, some kinds of invocations will automatically "splat" an array, others won't) - it's more heuristically determined in some cases. Generally I find that a bit distasteful - though on the other hand, if it truly is a successful approach (including in terms of long-term maintenance of the parser, etc.) I want to learn more about it.
Bow-ties are cool.
Man, all this time I thought "Python 3000" was just a fictional, futuristic-sounding version of Python that Charles Stross made up for his book Halting State. In Stross's world set in 2018, Python 3000 is one of the dominant languages used for distributed peer-to-peer networks running on cellphone nodes. (FWIW, I blogged about this briefly here.)
Yes, for the prototyping stage. The actual game is going to be written in Perl 6.
I expect the transition to run so smoothly that in 5 years, nobody will care that it happened at all.
*sigh* back to work...
True Part:
In Python version 2, 1/2 = 1 (integer math)
In Python version 3, 1/2 =0.5 (floating point math)
Funny part:
You can do some math on the version number and it comes out the same, even though the version number has changed. Because the divide operation changed too.
wait, it's not so funny after all. What was I smoking?
No, he's typing while Brazilian.
Int math:
(-2+1)/2 = -1/2 = -1
(-3+1)/2 = -2/2 = -1
those changes were mostly to fix poor coding practices like being able to run certain functions without braces (e.g print "hi").
Minor quibble: print wasn't a function, it was a statement. That is, it was on the same level as if/then, while, import, etc.
The thought is, though, that print is nowhere near as "central" to the language as if/while/import, and its functionality could just as well be handled with a function. - Which is what they did with 3.0
print (x)
Laws are horrible moral guides, moral guides make even worse laws.
Python 3000 is released - December 4, 2008
991 years ahead of schedule, no less. Take that, Microsoft!
I don't care if it's 90,000 hectares. That lake was not my doing.
What is messy about Python in OS X?
..until Guido finally figures out the correct use of whitespace.
I heard that Perl 6 is scheduled to be released in time for Christmas :-)
Besides, the _real_ end of days will be when Perl and Python and Ruby and Emacs are finally included in out-of-the-box Microsoft Windows installs.
Cut that out, or I will ship you to Norilsk in a box.
Reworked Unicode support is a big deal.
The servers that run our in-memory database handle UTF-8 data that consists overwhelmingly of code points below U+0080. But if Unicode in Python is anything like Unicode in Java (that is, UTF-16), we may have to double the RAM in our servers. In fact, if it's compiled as UTF-32, we may have to triple the RAM.
Good to see it move to doing things the Right Way by clearly separating strings and byte arrays, and standardizing on Unicode for the former.
But is it standardized on UTF-8, UTF-16, or UTF-32? These are all encodings of Unicode code points.
Now, if only we could convince Matz that his idea for Unicode support in Ruby 2.0 - where every string is a sequence of bytes with an associated encoding, so every string in the program can have its own encoding (and two arbitrary objects of type "string" may not even be comparable as a result) - is a recipe for disaster
I don't see how it would lead to disaster. When comparing differently encoded strings, convert them both to Unicode (either UTF-8 or UTF-16) and then compare them.
multiple versions of python can live happily together
How do I install Python 2.x and Python 3.x on a single computer running Windows, and then have the shell automatically choose the right EXE when I double-click a .py file? Unlike Linux and *BSD, Windows doesn't look at the #! line when determining which interpreter to use; it looks only at part of the file name.
True Part:
In Python version 2, 1/2 = 1 (integer math)
1/2 in Python 2.x is actually 0.
OK. well, what I was aiming for was:
True Part: In Python version 2, 1/2 = 1 (integer math) In Python version 3, 1/2 =0.5 (floating point math)
Accidental comedy microcosm of the pitfalls of dynamic typing. However, if you declare a var as int or float then the dynamic typing is a lovely feature. Out of interest, why did they decide to calculate 1/2 as float in Python 3?
I can see it now - they're going to have Guido van Rossum holding Python down and raping it.
Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
You ruined Python for me!
I believe it was because its "expected behaviour". To me, it makes sense, as something like:
for i in range(0, x/2):
Will still work either way for both types (int or double), and the int conversion is easier to do later then the conversion back.
I took a look at that page, and I became worried. Take the new string formatting, for instance. It's *much* easier to migrate existing software from C to Python using the old % format. The argument that % is a binary operator is stupid, that's what tuples are for.
Also, making the keys() method not return a list doesn't make sense. I often use mixed data sets, it's very convenient to be able to do somelist.append(x.keys()).
And so on, several of those changes will make it harder to do simple tasks without any advantage. Unfortunately, I can't say I'm enthusiastic about Py3k. Python was so good while it lasted....
The scheme of turning errors into U+DCxx is called "UTF-8b"
As currently stated it has a big problem in that it destroys the current lossless conversion of UTF-16 to UTF-8. This would mean that a system using UTF-16 but translating to/from byte streams using UTF-8b could not safely operate a backend that uses UTF-16, though it can now operate a backend that uses UTF-8. This is somewhat counter-intuitive.
But I'm wondering if in fact a true bidirectional lossless scheme between UTF-8 and UTF-16 is possible. I'm trying to figure it out, but it makes my head hurt:
1. Invalid UTF-8 would convert each byte to U+DCxx.
2. The conversion from UTF-16 should undo U+DCxx to the matching bytes. But it has to look at the result and make sure it is *not* a valid UTF-8 encoding. If so then it should translate the first one as in CESU to 3 bytes.
3. The UTF-8/CESU encoding of U+DCxx normally should be considered invalid. But the UTF-8 decoder has to look at the following bytes and determine if the result would be something the encoder would turn into CESU according to rule 2 above.
That is as far as I can figure it out. Unfortunately my impression is that each rule requires the opposite direction to detect more cases. I cannot tell if there is a stable result that is practical to implement.
No, he just sampled everything in the medicine cabinet... again
nothing better to do with my time than type parenthesis over and over. thank god they removed that silly ability to print 'hello world'.
Out of interest, why did they decide to calculate 1/2 as float in Python 3?
We got sick of explaining integer math to newbies on the python list each and every single day. So it was decided that if we used '//' for integer division and let '/' do what newbs expect we'd be saving ourselves muchos keystrokes in the long run.
Do over.... (shoulda installed Python 3 and tried it! oh well) I think this version might work a little better...
You really should have. I haven't installed yet, but your code, even the corrected version, should raise a TypeError since print(arg) returns None.
Better to be despised for too anxious apprehensions, than ruined by too confident a security. --Edmund Burke
Well, that was never an argument.
MABASPLOOM!
Sorry, I was sober when I wrote that.
I use that excuse a lot. Conversely, it's scary to code something while drunk then come back the next day and think "god, whoever wrote this is clever".
Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
It's scary to code something while drunk then come back the next day and think "god, whoever wrote this is clever".
I don't even need to be drunk! That happens to me regularly ... ah the ageing process.
Better to be despised for too anxious apprehensions, than ruined by too confident a security. --Edmund Burke
>>Any coder worth his salt is already indenting his code
As long as you are using your own code, and stick to your own conventions, then it's not a problem.
But what about when you are working with code from somebody else? You can not just look at it and tell if the original developer used spaces, or tabs. You have to do a hex dump, or something - what a pain.
And what if you want to cut and paste from a website? Or email code? Or post code to a news group, or whatever? Whitespace can be an issue in any of those cases.
I believe that even Guido has admitted the forced whitespace was a mistake.
Disclaimer: dumb guy here.
I used to program a lot for fun, spending countless hours of my childhood in front of our *gasp* Apple //e. But lost that spark, the closest I ever came to programming for years was hand-coding basic HTML pages.
Having been largely on the end-user side computing for a long time I've been trying to get back into programming. After many failed attempts (got lots of books on the shelf I bought then never read past page 7,) I stumbled upon Snake Wrangling for Kids Admittedly it's rather elementary, but I've been enjoying it.
Now I read in the summary, "intentionally backwards-incompatible"? What exactly does that mean? What I learned was for naught? I imagine (hope) little that affects me since my instruction has been fairly basic, but it still put some worry in my mind.
Yes, it was.
Finally somebody mentioned threading! I came in here specifically to find out whether 3.0 has any threading improvements. The Python FAQ has long said that they can't get rid of the global interpreter lock for two reasons: It might make Python twice as slow, and it would break all C extensions. If Python 3000 is going to break the C extensions anyway, this would be a perfect time to ditch the GIL. (I don't think anyone would object to making single-threaded Python twice as slow, except maybe web developers.)
I don't see any mention of it anywhere, though, so I'm not optimistic :-(
I read the grandparent post and it looked fine.
I looked at your post and and it all luked rong.
Wht idd you doo!
import antigravity is very cool but it's a darn shame that the print "Hello World!" example from the comic gives a syntax error. Sad.
Oh great. Just as I finished my first complete Python application. At least I made sure it's as compatible as possible with 3.0...
Anyway, 3.0 is great news! Can't wait to try it out.
I am not devoid of humor.
Zope is among the best Python applications (along with Twisted and others of course). How would Zope be better if re-written into Puthon-3.0?
Less is more !
But but but...
xkcd will fail the 2to3 checker.
That's great and all (no seriously, I got a good chuckle out of it), but it would work even if they hadn't changed division, because (-3+1)//2 is also -1.
Wait ... where's "profit!"?