Python 2.3 Final Released
An anonymous reader writes "Nineteen months in the making, Python 2.3 has just been released. With a plethora of changes since version 2.2, this release is definately worth the upgrade. Be sure to read the Release Notes and the Highlights file for more information."
I wonder what this means to the people at blender who just updated the python API
> "I allege that SCO is full of it" -Linus
Subcribers can't reply any sooner than non-subscribers
"I'd rather be a lightning rod than a seismometer." -Ken Kesey
from what I understand, comments can't be posted until it goes live to the general public
In 3... 2... 1...
Wow, finally Python 3! Are they as good as the original Monty Python? I didn't see the second Monty Python...Err... Is John Cleese still in Python?
I'm just waiting
for the trolls to start
complaing about
whitespace usage in
Python.
That, and what does this mean for improvments to my favourite distro's package management? (Gentoo!)
"f proper establish language like C , C++ , Perl, etc and other must be modern experimental choice like Python , Java , etc"
I assume including "Java" as an "experimental" language was a typo?
Seems the new release suffers from a certain DDoS bug.
What did it help you do? Work on your reading skills? Start your camp fire? Reach the top shelf?
How did it help you? Did you really need help? If so was this book uniquely helpful or do you think others would have helped too?
Are there other reasons why it was great? Was the author witty and entertaining? Or was he dry and to the point? Was his writing unusually clear and illuminating? Did he "speak to you"?
I'm not saying every comment here has to be a full book review, just that yours was devoid of any helpful content.
There's a feature I'd like to see removed.
Why ? What would the benefit be, beside breaking all existing python code ?
Heh... another useful book just sprang to mind, try Learning Python. There isn't really much between the two books... although a see Amazon offer a discount, wheras with the other one you don't get a discount... anyways your choice :)
I have over 70 freaks, do you?
At the top of the list of new features they have sets. The first paragraph says that sets are implemented by hashtables. I wonder whether it is really meaningless from the "practical" point of view to implement sets with data structures like red-black trees or Fibonacci heaps. The advantage of the latter over hashtables is a solid bound on the worst case running times.
Sounds like a Vlassic picle. More crunch.
Not, necessarily from this particular release, but in general the whole objective/functional thing which Python is doing really is very interesting and ought to be pushed further.
Some way to use Perl libraries would really kick ass too but I guess that's impossible without Parrot coming into reality.
Hexayurt - open source refugee shelter,
Check out Artima if you want to see Bruce Eckel's take on the Python language which, incidentally, with the addition of things like a logging API, and with long-existing additions like Jython, is beginning to look more and more like a viable competitor to Java.
Why?
Python carries a LOT of the same advantages, but with a dramatically accelerated prototyping and general development speed, and a few tricks of its own. Plus, via Boost, it interoperates with C++, too. I'm an avid Perl hack, but I have to admit that Python, which even has a whole API for basic game programming is looking more and more attractive for quite a number of things.
Download soon and often.
Chr0m0Dr0m!C
If you dislike the posts he makes, it might be a good idea to set him as a Foe, and browse at Foe -5. That way you will never have to look at his huge limp phallus again!
I have over 70 freaks, do you?
According to a couple of simple benchmark, Python 2.3 is about 20-30% faster than Python 2.2.3. Some of this speed-up was obtained by removing the SET_LINENO opcodes, which means that the difference is less impressive when comparing "python -O"; the rest was various careful tune-ups.
This is a big improvement. The biggest advantage of using a programming langage like python is the fast development time (5X-10X faster than C++). If the speed of execution of python scripts can be made comparable to compiled C/C++ code, then it would be awesome. Python programs can never be as fast as compiled code, but if the difference in the speed is not significant, it will be a big win for Python
I dislike trolling (as I assume this post will be modded) however, the misspelling of the word "definitely" has begun to irk me greatly. As a high school student who sometimes has to view the writing of my peers, I have to lower my expected standards. But when I go to read /. I'd assume that The-ones-who-post-stories-from-on-high might be able to spell check their commentary. Thank you for listening to my grammar rant.
.
why does the porridge bird lay his eggs in the air?
Mind telling us in a diary or future post how much you were able to get from the referrer? Just curious, I'm thinking of testing this out myself.
unless the story was posted by timothy, and it takes half an hour for him to unclick the "archived" button.
Do you even lift?
These aren't the 'roids you're looking for.
He's a troll. "Fu-Ling Yu" Get it? Haha and all that. He just pastes some links from the quoted article and get modded +5 with alacrity because of his charming "engrish". The stupid mods always fall for it.
At several schools Java is the language you start with in CS.
When I was going to school (late 80s) Pascal was the language of choice.
Please don't assume academics know jack shit about reality. Despite the fact that Pascal was a not-bad way to learn procedural programming, it was an error - we should have learned C. Ditto for the people learning Java today, including my girlfriend who learnt Java on her way to her BACS and has a mean ass hard time with certain portions of C as a result.
HBI's Law: Frequency of calling others Nazis is directly correlated with the likelihood of the accuser being Communist.
I've been learning Python Language for a while, but since I don't work with other programmers, it's taken me quite a while. I learned python the usual way (a mix between the on-line tutorial and Learning Python) and my fluency is improving.
I picked up this book recently while I was at a convention in Baltimore. I liked its organization: the book features a whole chapter on each datatype (strings, numbers, tuples, lists, and dictionaries). There are also chapters on Control Flow Statements, Functions, Modules, Files, Classes, and Exceptions.
Because of its organization, it's as useful as a reference as it is a tutorial. Each chapter contains progressively advanced examples that end up demonstrating the finer points of each topic.
For example, one hint was to use the vars() function creates a dictionary of the local namespace. This makes it useful when string formatting:The book does not cover advanced topics like Tkinter, Jython, or extending Python with C. Nor does it cover the Library modules (the Python online documentation is actually quite good).
"Python" is newer, cheaper (22 USD vs. 30 USD), and longer (410pp vs. 368pp) than "Learning Python"
I would recommend this book to anyone who would like to learn Python. If you're an intermediate Pythoneer, I agree with the parent: you will want to get "Python In A Nutshell".
My father is a blogger.
I hear this repeated fairly often, but I can not think of any really good reason why whitespace is bad. IMHO, any decent programmer worth his/her salt will whitespace their code anyway for sanity.
Just to be my own devil's advocate, here are some reasons I can think of off the top of my head. But I don't think any is sufficiently great for not using python strictly because of it's required whitespace syntax.
Actually, I want to become proficient in python, I've even got a few books, and just haven't gotten around to programming any application in it yet :-( But these are things I've wondered about (regarding the whitespace). Hopefully a seasoned veteran can point out why these aren't substantial problems.
- Putting a large block of code into a while or for loop.
-
TABS and order of whitespace
- For decently-complex programs there might be so many nesting levels that the indented code is spaced so far inwards that one needs ridiculously-wide displays for sanity.
Other than those rare or obscure issues, I can't think of any reason that mandatory whitespacing should hold someone back from python.In C, if I am quickly hacking some stuff together and realize I want to put 100+ lines into a for loop, I can put brackets around the code and possibly indent it later if I wind up keeping the code for long-term.
In python I'd have to manually go to all those lines and put the indent in. (I assume EMACS and other editors can do this automatically, if one knows the key combinations).
This confuses me. Does python keep track of instances of \t in an input file? Are they distinguishable from spaces? If at some nested level of indentation I'm at [tab][space][space], is a line of indentation of [space][space][tab] at the same nesting level?
If I'm at [space][space][space][space] can the next level of nesting be [tab]?
Personally, I don't think I've ever put more than 10 levels of nested blocks in a program somewhere, but I suppose it could possibly happen and might be a problem, especially of someone is restricted to 80-column screen for some reason.
make world, not war
for the same reason that a perl hacker will get a reasonably complex task done upwards of 100x or 1000x faster than an assembly programmer.
Isn't that better?
No cookie for you.
At one time people were really concerned with the whitespace situation in Python. While both sides made good arguments for and against having whitespace be syntactically important, it all boiled down to van Rossum's decision to make it so.
Then came the trolls. Lots of them. They saw that there could be bites to be had by just dangling the topic of whitespace out there. People were very willing to bite on the old arguments, but nothing was ever decided because all the arguments were just rehashes and the "experts" still saw mandatory whitespace as a crutch for stupid programmers, and Python "experts" said it helped them see where their blocks were. It didn't matter a whit, Guido went his own way.
But now, time has passed and Python's reliance on code beautifiers just to run has shown itself to be not quite the boon that it once purported to be. Yet Python enthusiasts still cling to the idea that whitespace ought to be syntactically relevant. So out come the old arguments, only this time the anti-whitespace crowd has more ammunition and the pro-whitespace gang is running out of bullets. But Guido goes his own way.
At some point the Python project will need to fork to release it from this whitespace requirement. In this day and age, only beginning programmers need such a visual crutch. Python has shown itself to be useful beyond Hello Worlds and Good Morning %s! It is time for the language to grow up. Too bad Guido still goes his own way.
That's mostly it. She hasn't even messed with a lot of that as a result - give her an API with clearly defined functions and everything is ok, but the details of memory allocation and cross-language linking (say, x86 assembly) are way out of her league. They shouldn't be though - if they had grounded her in C this would be a piece of cake.
Maybe it's a generational thing too - I was hacking on DOS machines when I got home from school at night and had a lot of access to hardware. Bit fields and playing with registers were a necessary part of what I was doing. I was writing blocks of assembly code regularly just to get things done. She works on systems that are so heavily abstracted you never have to get that close to the hardware, in fact you can't.
HBI's Law: Frequency of calling others Nazis is directly correlated with the likelihood of the accuser being Communist.
It could be worse, people could be learning Basic instead of Pascal and Java. At least they are slightly similar to C. I start programming with Basic and it's haunted me ever since.
For your second point, 10 levels of nesting is, IMHO, at least 7 too many. That's what subroutines are for. If you find yourself adding another level after three, it's probably time to look at your design.
"A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
The normal python compiler compiles to portable bytecode. I think you need some software that translate that to native (machine) code. It is called psyco, hosted on sourceforge.net. I don't know about its current status though.
Discussions on tabs and spaces can lead to flamewars in Python circles. Many people hate tabs, and a significant majority of code does not use tabs.
As far as screen width, that's no different in Python than any other language. Deep nesting is a sign of a program in need of refactoring.
Most of your problems would be fixed with a good python-aware editor.
:-)
Putting a large block of code into a while or for loop.
Well, if you had a large block of code to insert, why not make it a function and call it. Also, when you're working with Python, you quickly learn (or assign) the "entab" and "detab" commands, so inserting the tabs aren't a problem.
TABS and order of whitespace
Most people have their editors convert tabs to spaces
For decently-complex programs there might be so many nesting levels that the indented code is spaced so far inwards that one needs ridiculously-wide displays for sanity.
Someone who is using 10 levels of nested blocks isn't effectively refactoring. Extract method now and then...
My father is a blogger.
I used to use BASIC back in my CP/M days. Writing a 'Hammurabi' clone in MBASIC on a Kaypro 2+ never hurt me that much.
The lack of namespaces was the main hindrance - then again the programs could never get _that_ big on a 64k machine...
Most of the bad habits have gone away.
HBI's Law: Frequency of calling others Nazis is directly correlated with the likelihood of the accuser being Communist.
The only point of your post was to get your nice referral bonus for all the Slashdotters clicking through to Amazon.
Moderators should know to look out for this... it's way worse than karma whoring. Did you even read this book? I wouldn't be wondering this if your post wasn't so clearly a cash grab.
If so, it might help if you wrote something useful about why you're recommending it! (And I don't mean cut-n-paste from an Amazon review either...)
Booleans in Python at last, hurrah. We should see Boolean support appear in Jython soon too then, and an end to fiddling with 0's and 1's.
You don't seriously think that a tab/space/space is the same as tab/tab, do you?
That's the problem. Whitespace is INVISIBLE and there are MULTIPLE TYPES OF WHITESPACE. Relying on that kind of thing is dumb and blockheadish.
Luckily I don't have to work in the Python-using group. It's all Ruby for my team.
Alex Martelli has indeed written an excellent book. Actually, he almost wrote two excellent ones, since he is co-editor of _Python Cookbook_ too (but the latter is really more of a collaboration of dozens of people in the Python community than a book by an individual).
However, my book, _Text Processing in Python_, has at least one think over Alex's that is germane to this thread: I make a good effort to cover Python 2.3. I am quite confident that mine is the only book you can actually buy today that does so (I'm sure there will be more titles, and various updates, over time, of course). Don't let my title fool you, btw, I do a bit more than the title entirely admits to. But the title isn't a lie either, it really is focussed on the broad area called "text processing".
Anyway, there's nothing subtle in my plug. I really will get a couple dollars every time someone buys one (unlike the somewhat odd insinuation downthread about Sir Haxalot doing so). But then, I also invite everyone to read the entire text for free at:
http://gnosis.cx/TPiP/
So you can have something for nothing too, if you want.
David Mertz
Buy Text Processing in Python
Why is she learning C now?
Unless ur an embedded applications developer/kernel hacker/lean and mean
The reason I never bothered with Python is because of the whitespace issue, and I'll tell you why:
I don't trust that blocks are properly grouped.
When I program in C++, Java or even Ruby, and I create a new block, the first thing I do is close the block. Any code I put in the block I indent, but if the block grows, or my indenting gets goofy, I don't have to fear that my block is now improperly closing.
If I paste in a few quick lines of code for debug purposes, and it just happened to be indented differently than where I was pasting it, that would screw up the block closure unless I went and tabbed everything correctly. Sometimes, I *like* that the temporary code is indented wrong because it helps remind me to comment it out or remove it when I'm done debugging.
The whitespace thing is just too weird. It generates a lot of feelings that I might screw up my blocks. That sort of anxiety shouldn't be there; I shouldn't be so worried about blocks closing.
before i can get the new version after python.org is done with this slashdotting
post mirrors people!
vodka, straight up, thank you!
It would be nice if python had lists with a head and tail. It would also be nice if it had non sequential threads, a collector instead of reference counting, and maybe a decent attribute analysis so that the expression "a"[1] is barfed on before being
run.
Actually, it could. The PHP crowd blew every horn they could find when yahoo switched over to PHP, but AOL has been using python behind the scenes for a long time with little fanfare (or problems). So if it's AOL doing the upgrading, it might help your AOL downloads be faster.
Do you even lift?
These aren't the 'roids you're looking for.
Here's another one:
eval'd code.
Eval'ing anything more than complex than simple, pre-formatted blocks of text is going to cause a headache. One of the great things about interpreted programs is their ability to morph through eval calls. Having to ensure that blocks of text you paste together in code are properly indented to be interpreted via eval has got to be LOADS of fun.
Alex Martelli has written an article that talks about the changes from Python 2.2 to 2.3.
David, thanks for making your book available on-line. I'll be sure to look for a 'dead tree' version.
My father is a blogger.
Some of these features look useful enough but the one that stands out most as having a minor problem is importing modules from zip archives. That's all well and dandy but why not also support from other archives? tar + gzip or bzip would get better compression. The syntax looks like it could be a little clearer. Why not just 'import example.zip/mymodule' instead of messing with sys.path.insert() ? That sounds cleaner to me.
At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
If anything decimal shouldn't be there.
-Libertarian secular transhumanist
three, sir
Three!
In SOVIET RUSSIA... erm...NSA AMERICA, the Internet logs onto YOU!
Haunted? Leave it to dearly departed Edsger Dijkstra to say how it really is:
``It is practically imposible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.''
"My fingers Emit sparks of fire in Expectation of my future labours." William Blake
http://maps.yahoo.com/py/maps.py?Pyt=Tmap&ed=2eq1M up_0TpxXa5UN63mjyUSVQJsX5Sk2q8YXq2EXTawW.mGFYV8AHt JOL7B4CsQWw--&csz=Washington+DC&country=us
(purposefully not anchored)
Computers are useless. They can only give you answers.
-- Pablo Picasso
Personally (and knowing both languages well), I'd consider that a problem with C, not with Java...
Ceterum censeo subscriptionem esse delendam.
C and C++ are much more stable in both language reports and compilers, but Perl must be in the same so-called "experimental" group as Python and Java.
On the other hand, all of them must be in the experimental group, comparing to LISP (Scheme included), the language that survived since 1957 (amazingly - even still actively used, despite newfollowers like ML and Haskell), and FORTRAN, the language that existed for awhile since 1957 (well, perhaps too long for "awhile", but thanksfully it's dead anyway). And all of them are very real, comparing to really exotic languages. And they are practical, comparing to languages from our future.
Perhaps your school should give four groups of choice:
- dead languages from musiums: FORTRAN, Pascal, PL/1, COBOL, ADA, Smalltalk;
- practical languages for daily programming: Lisp, C, C++, Java, Perl, Python, Tcl, VB, Prolog, SQL;
- newcoming standards: ML, Haskell, C#, Mozart, Erlang, XML;
- real experiments, never came to real business, and barely will come: Icon, Snobol, Dylan, Curry, APL, Mercury;
However, I wonder, what's the academical point to separate artificially languages instead of requiring that students will take two language with at least two different parigms, like OOP vs FP?Less is more !
http://saveie6.com/
My major object to whitespace instead of { and }, or similar, is that it makes generating code using XSLT an absolute nightmare. It may not be a big problem to other people but it is to me. Using { and } you don't have to worry about the indentation, which is a pain in the ass to get right with XSLT. For hand written code it's not a problem, any decent IDE, i.e. emacs, will solve the problem. For autogenerated code I think it's a real minus.
development.lombardi.com
This guy is a TROLL people. All the others calling his bluff got modded into oblivion. Read some of them, and/or take a quick look at this dudes posting history. I've given up the -1 mod I had used to point this out instead, karma be damned. Anyone who makes a hobby of publicly mocking other racial groups while hiding behind an internet connection deserves to be called out.
"Gold still represents the ultimate form of payment in the world." - Alan Greenspan, 1999
I love python, I use it alot. That said, I hate the whitespace problems with the language. I cannot figure out why they don't at least *give* you the option of not using that horrible, horrible design. Why is it flawed? In my opinion it is flawed because a miss tabbed document cannot be reliably retabbed without knowledge of the code. For example:
- ->somethingelse;
d e additions but not this. Dumb, IMO. /rant
while 1:
---->while 1:
--------->dosomething;
xxxxx>i+=1;
Now where did the i+=1 go? I don't know. The way I deal with it is by doing this:
while 1:
---->while 1:
---------->dosomething;
---------->pass;
--
---->i=i+1;
---->pass;
But that's a poor solution, because it isn't a standard. Add f*ing c-like bracket block notation already! It isn't that hard and if you don't want to use it then don't. I don't get it they add all of these wierd obfuscated lets-see-how-long-we-can-make-a-single-line-of-co
-Sean
I really don't understand the problem here, and why people must cavil over a non-issue like required whitespace. If you don't like it, don't use it. End of story.
Our two chief weapons are trolling and casting nasturtiums
Our three chief weapons are trolling and casting nasturtiums and not paying attention to what we're saying....
So your favorite language is whitespace neutral - completely so, right?
No preprocessor lines (C, C++) that terminate on an end of line (which I consider whitespace).
No comments that terminate on the end of line? (Java, C#, C++, Perl, and so on )
How about end of line embedded in strings? Is that legal (in which case is the newline part of the string or not)?
Extra credit to anyone who can name a language that treats whitespace either as completely neutral in all situation (including tabs and end of line markers), or as meaningful in all cases. (And for slashdot regulars I'll rule out WHITESPACE up front).
And, of course, there is a solution. Just use
#begin
at the beginning of a block and
#end at the end of the block. Of course, like any sensible programmer you'll indent the block as you do.
And while you are at it, if you like semicolons, you can always add #; to the end of statements.
easy solution.
while something someval: #{
do.something()
while x 10: #{
print x
#}
#}
TODO: Something witty here...
If all anyone throws you is a straight pitch, you'll never learn to hit the curveball.
HBI's Law: Frequency of calling others Nazis is directly correlated with the likelihood of the accuser being Communist.
FORTRAN is most assuredly NOT dead. Just ask anybody involved in scientific computing. One good example of a modern scientific code, that is under heavy development, and is written in FORTRAN is FLASH.
-- HG Pennypacker, wealthy industrialist and philanthropist
Do you have a reference?
Everything I've read that came out of Dijkstra's mouth or pen reminds me of my English grad school days.
"Your undergrad professors taught Hemingway/Joyce/Fitzgerald/Some other author we don't like? You have a lot to unlearn before you can even grovel at our feet. Your mind is tainted."
Typical ivory tower bullshit. Granted, some teaching methods and ideological positions lend themselves to learning better than others, but this is typical academic posturing.
Sorry for the diatribe, but this is what's wrong with American education at all levels. You don't get promoted and you don't get tenure by defending the status quo, no matter how effective it is. You get attention by pushing a platform that is different and strident. It doesn't matter if you're right or not because the administration only cares about the bottom line (grants, enrollment, university prestige). If your college of whatever attacks the other university's college of whatever, you have the upper hand.
This, of course, plays right into the hands of the majority of professors who are pompous windbags, whose chief pleasure in life is fucking TAs and putting down the frosh to make themselves look smart.
Take the word of academics with a grain of salt. They have agendas too. For that matter, take all authority with a grain of salt. Use authority as a starting point if you must, but approach it with scepticism and develop your own opinions. If somebody tells you goto is harmfull, try it out. If it works for you, use it. In the case of goto, you'll probably find that it is harmful. But if you find the answer yourself, you've learned more than the answer. You've learned more than how to pass the exam.
As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
If I paste in a few quick lines of code for debug purposes, and it just happened to be indented differently than where I was pasting it, that would screw up the block closure unless...
Actually, the chances are it would generate a Syntax Error.
C//
I'm looking forward to playing with the datetime module. The old C-based API is just gross.
Actually it's not that difficult. You can build the block you want to evaluate as a string seperated by semi colons.
eg: while something: do_this(); do_that(); i += 1
Which is still bad, but not as bad as the program quietly operating incorrectly, which is still possible.
You are correct, I didn't think my answer/solution through fully. That said, I'm still not a fan of the whitespace requirement. It frustrates the heck out of me when I switch between vi and emacs on new/different systems.
-Sean
But often when a sophisticated bit of eval work is going on, you are loading the code from a file; a file that was hand-edited by a developer.
--Mike
"Not an actor, but he plays one on TV."
The first is NetLogo because its really awesome and you can do great things with it very easily. Ever try to simulate the spread of diseases in a C program??? The second is Dr Scheme which is a newer form of LISP. Teaches kids how to use functions and recursion. And the tortures of syntax. I just love () now. Rather i love (((()))) now. That portion of the course is concluded by us making our own number system with simple arithmetic functions. I think we used A's to represent a unit. Finally we conclude with Python. Basically it teaches us how to use a liner programming language.(none of the others really read top to bottom.) Overall a very good course. They also teach an introductory course that spends a whole term on python. Python has everything the more advanced languages have and its free in everyway. Plus it is much easier to read and teach with. I love it as does everyone who takes the course.
Unless ur an embedded applications developer/kernel hacker/lean and mean ....u can live ur whole programming life in ignorant bliss behind the facade that is the class library.
this of course coming from somebody who uses "u" and "ur"...
To quote the Python 2.3 release page:
Still a work in progress, but interesting.
Ciao
----
FB
Makefiles also require proper tabs for inputing rules.
Which is still bad, but...
Not particularly, as in Python you know not to do that. Myself, I have VIM macros for intenting and outcommenting and incommenting code in a wide variety of programming languages. What you are describing is what I call a "theoretical problem that does not turn out to be a problem in practice."
C//
On Guido's weblog you can read that he's made a wager on parrot's speed:
And let's not forget the opening lightning talk, which I presented together with Dan Sugalski: the Great Python Parrot Challenge. Dan believes that at OSCON 2004, Parrot will be able to execute Python bytecode faster than CPython can. I don't give him a chance. Dan bets me ten bucks, a round of drinks, and a pie at ten paces.
So the power of parrot against the regular python-interpreter-written-in-c. Nice wager, though!
Reinout van Rees
So, listen to the masters
I guess I should have said 'DON'T MOD THIS AT ALL!!', man people are idiots.
"A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
Does anyone know of a notebook interface for python as for Mathematica?
Running python in an emacs shell allows for erasing previous I/O but new input can only be added at the bottom, and old inputs can't be edited and rerun.
You should use sts=4 instead of ts=4. ts is best left to 8.
You don't seriously think that a tab/space/space is the same as tab/tab, do you?
Of course not. But as I understand (and as I do, and probably as the majority of Python programmers does), he meant that he only uses the tab key and the backspace key to indent his code. He has set up his editor so that there's only ONE TYPE OF WHITESPACE in his source files (":set expandtab" in Vim).
Besides, whitespace is not necessarily invisible. Using ":set list" in Vim can reveal the different types of whitespace in your file, and is very useful to spot trailing whitespaces, tabs and other problems.
Dijkstra was half joking, trolling even, in that remark about Basic. In the same piece are other hyperbolic comments such as "The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence." Have you really read any Dijkstra? He always seems level headed to me. Your rant seems to be about a different kind of person entirely. Are you seriously suggesting he should have been defending the status quo of Basic (and Fortran and Cobol)? That Basic is effective? If someone tells you goto is harmful, by all means try it out yourself, but also go and read the careful reasoning behind that little quote.
Python is definitely not typeless. It's actually strongly typed. But it uses dynamic typing.
Take a look at this article for clarification on typing models.
Stop worrying about the risks of nuclear power and start worrying about the risks of not using nuclear power.
Yes, you too can use a half-baked lisp without admitting to yourself, with the new improved Python 2.3!
Remember, Greenspun's 10th is not just a rule, it's the LAW!
morgan stanley use APL
Uhm, emerge supports binary packages.
Any technology distinguishable from magic, is insufficiently advanced.
For your second point, 10 levels of nesting is, IMHO, at least 7 too many. If you find yourself adding another level after three, it's probably time to look at your design.
This is the same kind of bullshit as saying goto is always evil.
emacs users probably have something similar.
All this said, I am of two minds regarding the whitespace -- enforced consistancy makes it a lot easier to decipher when reading at 3AM, but it means that the programmer has to do all the work when moving code around (ie there is little chance of there ever being a python equivilent to 'indent' or 'perltidy').
you should read everything on the internet as if it had "but I'm probably talking out of my ass" appended to it.
Check out guido's reponse to that exact question. Unit Test - "Everything"....
Anthony
Putting a large block of code into a while or for loop.
Do what you should be doing in any other braces-based language like C or Java -- refactor a big chunk of ugly code like this into its own private function or method and put an invocation of this method in the while loop instead. If you need to act on local variables, pass them into the function/method as parameters.
TABS and order of whitespace
When would you ever use both tabs and spaces in your whitespace in any other source code file? Some people standardize on tabs of a certain width (2, 4, or 8 chars), others such as myself standardize on spaces, but I never mix them up simply because I can't "see" the difference. All of my editors and IDEs are configured for this. (The official recommendation in the Python style guide is to use 4-space indentation, but this is not enforced.)
Also, there is an option that will generate warnings if you run the program using differing whitespace characters to let you know you've been bad.
For decently-complex programs there might be so many nesting levels that the indented code is spaced so far inwards that one needs ridiculously-wide displays for sanity.
Again, if you find this to be the case, then you are not refactoring appropriately. Read Fowler's Refactoring and learn how to break up your code into more-manageable chunks (plus other great tips).
"First you gotta do the truffle shuffle."
I suggest that all students be forced to learn C and assembler first, to get an idea of what's really, really going on under the hood. Students need to build moral fiber by implementing Yet Another Linked List, by tracking down memory leaks, and going through the agony of allocating a multi-dimensional array.
After this experience, they will:
a) Appreciate the glories of Java, Perl & co.
b) Realize that even with memory-managed platforms memory is still a limited resource, and that leaks can still happen.
c) Be able to harrumph at the next generation for forgetting what programming to the bare metal is all about.
Hey I've gotta run, my dad is waving some IBM punch-cards and a soldering iron at me.
Not to nitpick but the correct way to reference the head and tail of a list in Python is as follows: head = list[0] tail = list[-1] Please don't defile this beautiful language by posting incorrect code snippets.
Let me guess. You're still in high school or college and have never given a thought to the fact that your first real job will be as a maintenance programmer for an app/system that is probably older than you are. Those apps/systems were written in C. But I guess you'll just convince your boss to let you rewrite it in Java, right?
--
Promoting critical thinking since 1994.
My point still stands, though. You're going to see it anyway.
"A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
I have my own indention procedures as well, but if I don't follow them precisely, my code doesn't gain unwanted "features" as a result.
Give Ruby a good, solid try folks, really. Python has NOTHING on Ruby, trust me.
Whitespace that doesn't reflect a program's structure is a bug waiting to happen.
In that case, {'s and begin's are just an annoyance that take up extra space in many indentation styles, and introduce a class of errors.
People say that whitespace significance introduces its own class of errors. However, I've been bitten multiple times by bad indentation and bad {'s, while I've not once been bitten by python's usage of whitespace.
The easy rule is, don't use spaces in your indentation - only use one tab per nesting level. That way the 3 columners can see things at 3 columns, and the 8 columners can see things at 8 columns, and everybody gets to see things the way they most like, all from the same code. If you mix in spaces, then you end up stuck with one tabstop width unless you use a software formatter like gnu indent (which gives some people fits).
I have my own indention procedures as well, but if I don't follow them precisely, my code doesn't gain unwanted "features" as a result.
"In theory, there is no difference between theory in practice, but in practice there is."
Sir, I have never had a python program gain "unwanted features" using the *theoretical* weakness that you believe exists. Further, I would assert that this problem seldom ever actually arises, amongst beginners and experienced Python coders alike.
C//
I believe you. But I don't believe I would be as lucky.
Between whitespace problems and my fear of whitespace problems, I don't know which is worse. Even if, in actuality, there were NO whitespace issues at all, my reasoned fear that there are is just too much stress to have while programming.
I liked everything I have heard about Python, except for that one thing, and it's too much to overlook.
Your sole point is that a "miss tabbed document" (sic) breaks the code. Could you explain where this altered tabbing comes from? Would you similarly deride a language for not being impervious to random removal of characters?
I've written 10's of thousands of lines of Python code and have never had (that I can recall) a single problem with indentation, blocking or scope. I must admit, I had exactly the same knee-jerk reaction to Python as you before actually trying it -- it took all of one day of using it to wash away any doubts. This is after years of coding C++ and Java, BTW.
Side note: if you're terminating lines with a semicolon in Python then I doubt you "use it alot" (sic).
This was my feeling for years, before I picked up Python. Your fear is an irrational fear. The only legitimate problem I've run into with python programs are when functions get very long, and you'd like to quickly jump from begin-to-end of scope (or vice-versa). While a python-aware editor could do this for you, I don't use one, will never use one, and so have to occasionally tolerate that annoyance. Usually it's a good sign that the function needs to be refactored a bit, but so it is.
:)
And the white space problems aren't as extant as most people think. For example, in Python, this is legal:
>>> a = [
1,
2,
3,
]
>>> a
[1, 2, 3]
>>>
Note that Python, at cetain points, actually becomes white space (newline/indent) *insensitive*. As it turns out, it does so at all the places where you might want it to.
Python is about the most readable programming language ever written. That's saying a lot for it, and implies something about how it handles white space as well. For one, your eye is not overloaded with tons of symbols as it might be in, say, Perl.
C//
What if you had to retab a large block of code because you added another while, an if statement, or a handler? Where do you stop tabbing? Also, have you ever tried editing python code in vi and emacs? It doesn't work with default settings. Your statement, however, is the perfect example of why this annoys me. You simply wipe your table clean by saying it isn't important. It *obviously* is important or it wouldn't have hung around this long...
-Sean
The fear probably is irrational, I can't argue that because I ran away from Python before I really found out. I have to admit that I'm just too much of a Ruby fan to even want to address the issue.
Strangely, many of the world's preeminent CompSci institutions disagree one hundred and ten percent. At MIT, the CompSci curriculum begins with--and throughout remains heavy influenced by--Scheme. Why? Because hardware changes. Because the things you learn about computers by programming in C are really limited (not every computer is a register-based machine). Because learning how a specific computer works doesn't teach you bupkis about how computation works.
... etc., etc., etc.
For that you need a formal model of computation. There are two principal formal models of computation: there's the Turing Machine and there's the Lambda Calculus. We don't have very many languages with explicit support for Turingisms. On the other hand, we've got several languages with explicit support for Lambda--from LISP and Scheme to ML and
First learn about computation. Then learn about how to apply computational theory to a specific architecture.
That's the way MIT, Stanford, et al. are teaching CompSci nowadays. That's the way I was taught CompSci at the university level--our Intro to CS course was taught in Pascal (yes, I went to college that long ago), mainly because of demands that students learn something "practical" in CS141, but as soon as you got past Intro it was heavy on functional languages and lambda.
I wholeheartedly endorse it.
I have read a number of books on python over the years. Last year I bought 'Python Programming Patterns'. I would strongly recommend this book to anyone who is already experienced in programming. It literally goes into very deep detail about many many features of the language.
He has later retracted his statement, but it is not positive.
And this post sums up what Ruby thinks of Bruce :-)
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
OK, I'll make this simple so that the logic is completely transparent:
In Java, program structure is defined by the programmer inserting appropriate "{"s and "}"s. Indentation can be implicitly determined by the editor based on this structure.
In Python, program structure is defined by the programmer inserting appropriate indentation. (If you wanted to), "{"s and "}"s could be implicitly determined by the editor based on this structure.
Your argument is that, with Python, an editor cannot magically retab the document as it can with Java. An equivalent statement would be to deride Java based on the fact that an editor cannot magically insert (redundant) "{"'s and "}"'s based on the indentation as it could in Python.
You ask "where do you stop tabbing?" after inserting an if statement. The answer, of course, is that in all languages, creating a new block is changing the structure. In Java, you do this by inserting your braces. In Python, you do this by changing the indentation. Your question is really: "how does an editor determine this implicit presentation based on the structure given by the programmer?". In Python they are the same thing so the answer is trivial.
To answer your question: I've exclusively used emacs as my Python editor for several years and have never touched any emacs settings w.r.t. Python.
Yep. Python does a little startup dance looking for and loading default modules and directories, so it has more startup overhead. You can probably see from the syntax that the language isn't really intended for one-liners though.