Slashdot Log In
The Evolution of Python 3
Posted by
ScuttleMonkey
on Mon Jan 12, 2009 04:02 PM
from the all-growd-up dept.
from the all-growd-up dept.
chromatic writes to tell us that O'Reilly has an interview with Guido van Rossum on the evolutionary process that gave us Python 3.0 and what is in store for the future. "I'd like to reiterate that at this point, it's a very personal choice to decide whether to use 3.0 or 2.6. You don't run the risk of being left behind by taking a conservative stance at this point. 2.6 will be just as well supported by the same group of core Python developers as 3.0. At the same time, we're also not sort of deemphasizing the importance and quality of 3.0. So if you are not held back by external requirements like dependencies on packages or third party software that hasn't been ported to 3.0 yet or working in an environment where everyone else is using another version. If you're learning Python for the first time, 3.0 is a great way to learn the language. There's a couple of things that trip over beginners have been removed."
Related Stories
This discussion has been archived.
No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
Combine them.... (Score:5, Funny)
Re: (Score:3, Funny)
Lemme guess... you're a student of the Sun Microsystems'-sponsored Bill Joy School of Version Numbering?
Re:Combine them.... (Score:5, Funny)
Either that or he's a Winamp developer.
Parent
Re: (Score:2, Funny)
Same thing.
Evolution? (Score:3, Funny)
Shouldn't that be intelligent design? Otherwise we'd have way more python flavors.
Re: (Score:2)
Well, Python has a distinct, well known creator, so I guess it does qualify
Re: (Score:2)
Re: (Score:3, Interesting)
Re: (Score:2)
Re: (Score:3, Funny)
I hear it bit its tail and now just slowly slithers around in a circle...
Re: (Score:2)
"Python species"
There, fixed it for you! ;)
Probably not an issue for beginners? (Score:3, Interesting)
I just started learning Python a few weeks ago when I got laid off from my QA job. I imagine I'm not to the point yet where the language differences between 2.x and 3.x are going to matter?
Re: (Score:3, Informative)
Unless you're trying to learn how to code Django apps, which won't work on Python 3.0. Neither will a lot of other 3rd party modules.
Re: (Score:2)
No Twisted? Well, no Python 3.0 for a bunch of my apps for a while...I did mention Django, though, specificially because the Django devs have no definitive plans to update it 3.0 at this time and it's not inconceivable that they might never update it for 3.0.
Sounds like FUD - Django will update to 3.0, it will just take time:
http://docs.djangoproject.com/en/dev/faq/install/#can-i-use-django-with-python-3-0
The upgrade won't be exceedingly hard either. It could be done people not part of the django core team, even... Summer of code 2009?
Re:Probably not an issue for beginners? (Score:4, Informative)
Not really. Keep learning 2.x as you were. Quoth Guido:
http://www.artima.com/weblogs/viewpost.jsp?thread=211200 [artima.com]
Ignore 3.0 for now. If you encounter it, there is a handy script to help update your code, though most of the language is unchanged. The biggest gotcha is that print is now a function print() rather than a statement.
Parent
Re: (Score:3, Insightful)
Philosophical. Pragmatists like myself can't stand it.
Re:Probably not an issue for beginners? (Score:4, Insightful)
The reason is consistency. If I have:
print "Hello world."
and
print("Hello world.")
Which do you suppose is easier to find-and-replace to:
o.write("Hello world.")
The second, of course, because you can do it without a wildcard.
Parent
Re: (Score:2, Interesting)
Trip over beginners? (Score:3, Funny)
There's a couple of things that trip over beginners have been removed.
Ah, yes, I remember python tripping over me. It's actually pretty impressive that a snake figured out how to trip, why take out that feature? It seems like you're knocking it back a notch in the evolution toward legs.
Re: (Score:2)
Like basic grammatical structure, for instance? When did Palin become a Python dev?
Re:Trip over beginners? (Score:5, Funny)
Well, Common Lisp stole my bike.
Parent
Getting into Python 3 (Score:4, Informative)
For those interested, IBM is running a primer series [ibm.com] on the new language/runtime features.
There's also this [python.org] older (but still relevant) PEP that explains things that did not change between the 2.x series and 3.0.
Personally, I'm not looking forward to migrating existing code bases (especially non-trivial ones) to 3.0, but I'm planning to do all new development against it (of course assuming that the various packages I use have ports).
For Python trivia lovers, here [slashdot.org] the the actual moment in time when 3.0 was let loose on the world. I'm such a sentimental geek :)
This sentence fragment. (Score:3, Funny)
So if ( you are ( not ( held back by ( external requirements like ( dependencies on packages ) or ( third party software that hasn't been ported to 3.0 yet )))) or ( working in an environment where everyone else is using another version )).
The above sentence fragment is apparently a verbal quotation where Guido van Rossum forgot he used the word "if" when he was somewhere in the middle.
Re: (Score:2)
Re: (Score:2)
If you code in Notepad, maybe :)
Unicode & toolkits (Score:2)
Python 3 mostly changes things that deal with unicode (i.e. it uses unicode an it's "text" object, like Java).
If you don't care about unicode that much (e.g. you mostly deal with development tools, iso-latin1/ascii encoded files...) there is absolutely no rush to hop on the bandwagon. And perhaps you just hate unicode as a concept ;-).
I predict that the bandwagon will start rolling ~ Q2 / 2009, when toolkits like PyQt4 for 3.0 are materializing.
Re: (Score:3, Informative)
I've read your previous posts. You weren't making any sense back then, and you aren't making any now either. However, for some reason your trolling seems to go well with the mods every time.
It's a fact that the Unicode support in Python is not perfect (see e.g. this post [cmlenz.net]). However, every and any issue you might have with Python 3 internal representation of Unicode strings, you are bound to have with Python 2 as well. The only thing that has changed is that the unicode and str types got replaced with str and
Oh good. (Score:5, Insightful)
So whitespace block delineation is finally out, in favor of braces? :P
Re:Oh good. (Score:5, Insightful)
I'll preface this by saying that I program primarily in brace-based languages.
Braces suck in the worst possible way as a method of delineation. Let me give an example:
That's clearly the suck, so we break it out like:
...at which point we realize that the braces are basically useless, since the code is unreadable without the whitespace. Python just forces you to use a readable formatting, and it's not all that hard to get used to.
Parent
Re:Oh good. (Score:5, Insightful)
at which point we realize that the braces are basically useless, since the code is unreadable without the whitespace.
No, it means the code is hard to read, but it still works. You can reformat that block, or you can change the spaces (tabs, number of spaces), and it will still work. In Python, it may look okay, and be readable, but it won't work.
I guess it is a matter of priorities.
BTW, I like Python (and have almost given up on Perl 6), but the white space thing drives me crazy.
Parent
Re:Oh good. (Score:5, Insightful)
The whitespace issue is a red-herring: most people get used to it quickly and it's not as strict as it sounds (you can mix-and-match tabs and spaces, as long as you are consistent for each *block*; not even an entire .py file). There's two real-world problems with it: copy-and-paste and generating Python code. Both are much less common than looking at badly-formatted code that it takes a bit to mentally parse which brace-delineated languages have.
Parent
Re: (Score:3, Interesting)
The code that implements it is surprisingly short [timhatch.com].
Re: (Score:2)
Backwards Compatibility (Score:2, Interesting)
The question is: is this work worth the upgrade to python 3.0? I'd say on the whole, the
Re:Backwards Compatibility (Score:5, Interesting)
I think that whenever a group releases a new version of their language, they should strive to make it (mostly) backwards compatible.
That's why they keep releasing 2.x versions that are backwards compatible.
This means that very large projects have a lot of work to do to bring their project over to the new specification.
Very large projects can stay with the 2.x series (along with a big portion of users) just fine.
The question is: is this work worth the upgrade to python 3.0? I'd say on the whole, the changes do not contribute enough to the usability of the language to make it ultimately a worthwhile transition to make. I haven't seen really any compelling features in Python 3.0 that would provide enough incentive for me to spend hours of grunt work making all my code workable in Python 3.0.
And you shouldn't, since it would probably be a waste of work. 2.x is a rock-solid series that is years away from obsolescense, and new serious projects started right now should pick 2.5 / 2.6. Try starting to use Py3 for projects where it fits - your command line scripts, self-contained internal applications... and ramp up the stakes when new libraries are ported.
A programming language deserves a "cleanup" every now and then - this is such a thing. Hey, people have survived worse things, like gcc version changes, Qt3 => Qt4, Gtk 1 => Gtk2...
Parent
Re:Roland Piquepaille: a case study in madness (Score:4, Funny)
I don't think will be a problem any more
Parent
Re: (Score:2, Informative)
The name Python originally came from Monty Python, so you're about 18 years late on that joke.
Re: (Score:2, Insightful)
Re: (Score:2, Insightful)
I thought the same as you once, but I changed my mind. Now the braces just plainly, insanely annoy me.
Moreover, you cannot imagine how much time is wasted in typing something that has absolutely no meaning: you have to indent anyway. Braces are just a waste of your time.
Re: (Score:3, Insightful)
On the other hand, I've spent at least a full work week of my life fixing problems due to whitespace. Guido made a major fuck up there- by removing braces but not strictly defining whitespace, he's created a language where it's possible to have two identical looking pieces of code do very different things. If he had said that it must be indented by exactly 1 tab or exactly 4 spaces or whatever other measure and everything else would throw a syntax error, it would have been fine. As it is I'd say about 1
Re: (Score:3, Insightful)
I think it's ridiculous that people's biggest complaint about Python is that it's whitespace sensitive. Any frustrations with it are easily solved by using the proper tools.
Learn a text editor, and this isn't an issue. In emacs, C-c C-q will properly tabify the function you're in, and tabs should behave mostly sane thereafter.
Re:In all seriousness (Score:5, Insightful)
I've edited Python in vi, Notepad, SciTE, Geany, and other editors without any problem. Never used emacs though. If whitespace is causing bugs in your team's code you need to (a) introduce process or (b) lose some dead weight from your team. For (a) you can standardise on editor and whether to use tabs or spaces, or you can get the coders to end a whitespace block with a comment, eg # endif. I've only been using Python a couple of years but my experience so far suggests the problem is with you and not the language.
Phillip.
Parent
Re: (Score:3, Interesting)
A good editor should re-indent the pasted code automatically. In VIM you can use :set ai, si.
Re: (Score:3, Insightful)
I would be interested to see an example of Python code where a change to whitespace causes two identical-looking pieces of code to do two different things.
The only issues that *ever* come up in such a scenario is a SyntaxError, and pretty much the only reason they ever happen en masse is due to indiscriminate copy-and-paste coding.
Syntax errors can barely even be called bugs, and in any significant project the amount of time you're going to spend dealing with them is easily dwarfed by the *real* bugs that a
Re:In all seriousness (Score:4, Insightful)
This is easy to demonstrate
for i in myarray:
** Do some stuf here, use spaces to delimit. Note we are already inside a function or class. That is, we are not at the first indent level
print "Hello world" //Note this line is tab delimited. It looks likes its at the right indent level but its not.
Now you expect the code to print hello world a load of times but it will actually do it only once.
Its easy to extrabolate this to less trival problems
Parent
Re:In all seriousness (Score:5, Informative)
Parent
Re:In all seriousness (Score:5, Insightful)
If he had said that it must be indented by exactly 1 tab or exactly 4 spaces or whatever other measure and everything else would throw a syntax error, it would have been fine. As it is I'd say about 15-20% of the time I spent doing Python was spent fixing these kinds of bugs.
I have to assume that most of your time doing python has been spent copy/pasting code off the web. I've been coding python nearly daily for a couple years now. I've rarely made indentation errors, none in the last few months, and only once have I ever had an indentation error that took more than 10 seconds to debug. The thing is, most indentation errors are so visibly clear that it's really quite hard to make them.
If you're actually having problems with multiple spaces looking like tabs, you can use the -t option to make it throw an error if you use a mixture of tabs and spaces, but it really shouldn't be that hard.
Parent
Re: (Score:3, Insightful)
Guido made a major fuck up there- by removing braces but not strictly defining whitespace
Stop. First, the whitespace rule in Python *is* strictly defined.
The formal, exact, unambiguous specification of how Python interprets whitespace is in the official language reference - Lexical analysis [python.org].
It's pretty wordy, but I've studied it and it's quite precise. The relevant section is here:
"Firstly, tabs are replaced (from left to right) by one to eight spaces such that the total number of characters up to and including the replacement is a multiple of eight"
This is exactly the same as the default behaviour of Unix `expand`.
[Guido has] created a language where it's possible to have two identical looking pieces of code do very different things.
It depends what you mean by "looking". To you, perhaps 1 tab looks the same as 4 spaces. To me, maybe it looks the same as 2 spaces. To Jeff, maybe it
Re:In all seriousness (Score:5, Funny)
Yes.
Example program:
class MyClass(object): #{
def myfunction(self, arg1, arg2): #{
for i in range(arg1): #{
print i
# whoops, forgot to close that bracket!
#}
#}
Parent
Re: (Score:3, Informative)
For distributions with dependency management (Ubuntu, Debian, Fedora, any modern distribution), this isn't a hard issue -- in the distros I'm familiar with (Debian/Ubuntu) the different versions of python are just separate packages, apps have a list of dependencies and can list that they depend on a certain version of python, and the python package is just a dummy