Slashdot Mirror


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."

29 of 371 comments (clear)

  1. Re:Reviewing a book 101 by Sir+Haxalot · · Score: 5, Informative

    Ask any Python aficionado and you'll hear that Python programmers have it all: an elegant language that offers object-oriented programming support, a readable, maintainable syntax, integration with C components, and an enormous collection of precoded standard library and extension modules. Moreover, Python is easy to learn but powerful enough to take on the most ambitious programming challenges. But what Python programmers have lacked is one concise and clear reference resource, with the appropriate measure of guidance in how best to use Python's great power. Now Python in a Nutshell fills this need.

    In the tradition of O'Reilly's "In a Nutshell" series, this book offers Python programmers one place to look when they need help remembering or deciphering the syntax of this open source language and its many modules. This comprehensive reference guide makes it easy to look up all the most frequently needed information--not just about the Python language itself, but also the most frequently used parts of the standard library and the most important third-party extensions.

    Python in a Nutshell focuses on Python 2.2 (and all its point releases), currently the most stable and widespread Python release. This book includes:

    A fast-paced tutorial on the syntax of the Python language itself

    An explanation of object-oriented programming in Python, covering both the classic and new-style object models

    Coverage of other core topics, including exceptions, modules, strings, and regular expressions

    A quick reference for Python's built-in types and functions, as well as the key modules in the Python standard library, including sys, os, time, thread, math, and socket, among many others

    Reference material on important third-party extensions, such as Numeric and Tkinter

    Information about extending Python and embedding it into other applications

    Python in a Nutshell provides a solid, no-nonsense quick reference to information that programmers rely on the most. This latest addition to the best-selling "In a Nutshell" series will immediately earn its place in any Python programmer's library.

    Synopsis
    In the tradition of O'Reilly's "In a Nutshell" series, this book offers Python programmers help remembering or deciphering the syntax of this open source language and its many modules. This comprehensive reference guide should make it easy to look up all the most frequently needed information - not just about the Python language itself, but also the most frequently used parts of the standard library and the most important third-party extensions. The book includes: a fast-paced tutorial on the syntax of the Python language itself; an explanation of object-oriented programming in Python, covering both the classic and new-style object models; coverage of other core topics, including exceptions, modules, strings, and regular expressions; a quick reference for Python's built-in types and functions, as well as the key modules in the Python standard library, including sys, os, time, thread, math, and socket, among many others; reference material on important third-party extensions, such as Numeric and Tkinter; and information about extending Python and embedding it into other applications.

    Happy? :)

    --
    I have over 70 freaks, do you?
  2. Re:Second fucking post by Sir+Haxalot · · Score: 2, Informative

    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?
  3. definately? by derrith · · Score: 1, Informative

    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?
  4. Re:Why Python is good at our university by The+Bungi · · Score: 4, Informative

    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.

  5. Re:question to practical programmers by SilentStrike · · Score: 2, Informative

    Essentially, hash tables are preferred over balanced trees because they are usually faster in practice.

    Python developer showing preference to hash tables over balanced tres.

    I would also like to see balanced trees in the library, if for nothing more than sometimes ordered iteration is more useful than fast lookup, but oh well. I believe having hash tables but not balanced trees is much less bad than the other way around (like standard C++), in which there are balanced trees but no hash tables.

  6. Better than Learning Python. by Big+Sean+O · · Score: 5, Informative
    Learning Python is getting quite dated (it covers Python 1.5). I recommend Python: A Visual Quickstart Guide by Chris Fehily. It's a better book than Learning Python, at least.

    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:
    >>> quality = 'color'
    >>> thing = 'orange'
    >>> print "What %s is an %s?" % (quality, thing) # useful for simple formatting.
    What color is an orange?
    >>> print "What %(quality)s is an %(thing)s?" % vars() # more legible and useful.
    What color is an orange?
    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.
  7. Re:Its 20-30% faster !! by elflord · · Score: 5, Informative
    If the speed of execution of python scripts can be made comparable to compiled C/C++ code, then it would be awesome.

    Out by an order of magnitude, and not getting closer any time soon. Last I checked, it's out by a factor of 100 or so for small operations (loops, etc) But this isn't a problem in practice -- one can code the speed-critical stuff (whether that be objects, or functions) in C or C++, then wrap them in python, and enjoy all the benefits of python.

    Also, it often happens that 1% of the speed of C and C++ is actually good enough. Sounds slow, but only compared to C and C++ which may be well over 100x faster than what's required.

    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

    It is much slower, and unavoidably so. It's a very dynamic language, and this has consequences as far as performance is concerned.

  8. Re:I see whitespace is still syntactically relevan by Ian+Bicking · · Score: 4, Informative
    Putting a large block of code into a while or for loop.
    Editor support is very useful in this case. In Emacs you can indent/dedent a region with C-C > and C-C < (i.e., control-C, then > or <); you mark a region by going to one end, hitting C-space, then putting your cursor at the other end (or dragging with the mouse).
    TABS and order of whitespace
    Python treats all tabs like 8 spaces, no matter the location. But mixing tabs and spaces is considered bad and potentially dangerous if you display tabs as something other than 8 spaces. You can use the -t flag to Python to warn you about this.

    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.

  9. Shameless plug by Lulu+of+the+Lotus-Ea · · Score: 4, Informative

    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

  10. Re:ATTENTION! by larry+bagina · · Score: 5, Informative
    Upgrading to Python 2.3 will _not_ increase your skill levels, and will NOT make your AOL downloads faster!

    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.

  11. Really, Dr. FoolingYou by thelexx · · Score: 3, Informative

    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
  12. Re:I see whitespace is still syntactically relevan by smoondog · · Score: 2, Informative

    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:

    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;
    --- ->somethingelse;
    ---->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-cod e additions but not this. Dumb, IMO. /rant

    -Sean

  13. Re:From relevancy to troll and back. Whitespace by brian_olsen · · Score: 2, Informative

    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.

  14. Nobody Expects the Whitespace Inquisition by jefu · · Score: 2, Informative
    Our chief weapon is trolling

    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.

    1. Re:Nobody Expects the Whitespace Inquisition by ProfKyne · · Score: 2, Informative

      And while you are at it, if you like semicolons, you can always add #; to the end of statements.

      Actually, Python allows the user of semi-colons at the end of statements in most cases. Think of it more as if Python doesn't enforce them.

      --
      "First you gotta do the truffle shuffle."
  15. Re:how about lists by axxackall · · Score: 2, Informative
    head=list[0]
    tail=list[1:]
    Does it help?
    --

    Less is more !
  16. Re:Platform Competition? by mixmasta · · Score: 3, Informative

    Maybe you are right but I have written several apps in python and java, and the ones in py left java in the dust. Much less memory for the runtime too.

    --
    #6495ED - cornflower blue
  17. Re:Its 20-30% faster !! by jgardn · · Score: 3, Informative

    Python is running on a virtual machine that uses a stack. This is what pretty much every high level modern language does, including Perl and Java.

    However, with the addition of Parrot, Python, as well as Perl, will be running on a virtual machine that uses registers rather than a stack. Register based machines are much faster than stack based machines.

    Damian Conway, in a presentation at the Seattle Perl User's Group, demonstrated that you can actually get code that is written in perl that runs only a small factor (like 4 or 5 times) slower than C, rather than many orders of magnitudes (like 100 or 10,000 times) slower. This speedup will benefit Python as well, when it is ported to Parrot.

    In short, Python and Perl, and every other language that is ported to Parrot, will kick some serious butt, and put a lot of C programmers out of work.

    --
    The radical sect of Islam would either see you dead or "reverted" to Islam.
  18. Re:I see whitespace is still syntactically relevan by golan · · Score: 2, Informative
    Well, It is said in the linux source code documentation. I know, it's C, but it simply says in /usr/src/linux/Documentation/CodingStyle:
    [...]
    Rationale: The whole idea behind indentation is to clearly define where
    a block of control starts and ends. Especially when you've been looking
    at your screen for 20 straight hours, you'll find it a lot easier to see
    how the indentation works if you have large indentations.

    Now, some people will claim that having 8-character indentations makes
    the code move too far to the right, and makes it hard to read on a
    80-character terminal screen. The answer to that is that if you need
    more than 3 levels of indentation, you're screwed anyway, and should fix
    your program.
    [...]

    So, listen to the masters ;-). I suppose this piece of advice is worth noting in python too, well, at least the force indentation...
  19. Re:Bastion disabled by samih · · Score: 3, Informative

    The new introspection facilities introduced in version 2.2 allow one to go around Bastion and rexec restrictions.

  20. Re:Notebook? by costas · · Score: 2, Informative

    Google for IPython, it does some of what you want and a lot more.

  21. Python is actually strongly typed. by XNormal · · Score: 4, Informative

    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.
  22. Re:Its 20-30% faster !! by GnuVince · · Score: 2, Informative
    Quote from elflord:
    It is much slower, and unavoidably so. It's a very dynamic language, and this has consequences as far as performance is concerned.

    Common Lisp is a very dynamic language, but compilers like CMUCL and SBCL produce programs whose performances match those of C and C++. See http://www.bagley.org/~doug/shootout/ and see how well CMUCL performs.

  23. Re:question to practical programmers by Matts · · Score: 2, Informative

    Perl has fixed this in the soon-to-be-released perl 5.8.1

    --

    Matt. Want XML + Apache + Stylesheets? Get AxKit.
  24. Re:question to practical programmers by scrytch · · Score: 2, Informative

    If you want to see an interesting container implementation (based on a trie, behaves like a hashtable) check out Judy Arrays. Judy is bogglingly complex, but it boils down to optimizing for the CPU cache.
    Judy looks fairly promising for some applications I'm looking at. The benchmarks I ran are sort of bogus though since I'm not causing fragmentation by doing other things between inserts and deletes. I suppose the moral of the story is, preallocate if you know your structure is going to get big.

    --
    I've finally had it: until slashdot gets article moderation, I am not coming back.
  25. Re:impact... by sketerpot · · Score: 2, Informative
    Pthon 2.3 was designed with backward compatibility in mind. All your old programs should work with 2.3 if they work with 2.2.2, and you'll get some speed improvement. Of course, if you use 2.3-specific modules like logging (based on log4j) and sets (set operations, using dictionaries internally), those won't be compatible with 2.2.2 unless you copy the files from the standard library, which should work.

    In short: don't worry about it. The python developers already have.

  26. The real way to get some head and tail by sblack · · Score: 2, Informative

    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.

    1. Re:The real way to get some head and tail by ameoba · · Score: 3, Informative

      list[-1] is the last item in the list. To anyone coming from a functional programming background (such as lisp), the head of the list is the first element and the tail is everything else.

      Lisp style cons lists are essentially a big nested set of tuples

      [1, 2, 3, 4, 5]

      translates to

      (1, (2, (3, (4, (5, _)))))

      so head (the lisp CAR) is the first element of this two item tuple, tail (lisp's CDR) is the 2nd element, or the rest of the list.

      --
      my sig's at the bottom of the page.
  27. Re:Platform Competition? by GooberToo · · Score: 2, Informative

    Was nice of you to post as AC. Seems your reading skills need some work. Which makes it obvious why you posted as AC. I said, "it's not worth talking about". I never said Java wasn't faster. That's actually a fairly old version of Python and Java in that comparision. Now then, throw in a benchmark which actually allows for Java's GC to kick in, then you'll see Java's performace stumble, fall and simply cry. In turn, it significantly closes the performance gap. That's the biggest problem with by-n-far, most Java benchmarks. That is, they are short enough to prevent GC'ing from occuring. As such, it looks good on paper but performs much worse in real world applications. Python, on the other hand, constantly pays its collection dues when something falls out of scope. As such, most Java versus Python comparisions heavily bias toward Java. Create a benchmark which runs long enough for Java's collector to kick in, and you'll see a world of difference. Oddly enough, many real world applications help show this difference without problem.

    The fact that python constantly collects is one of the reasons why python has a much smaller memory footprint than java. Don't forget that Python just got 10%-30% faster too. That too should significantly help close the remaining performance gap. Still even more funny, Python has not been significantly optimized to date. That means you can continue to expect python's performance to increase. Java, on the other hand, is pretty much about as fast as it's going to get.

    You need to learn how to compare apples to apples and even know what you are talking about. All of the above is why, in real world terms, the performance differences between Java and Python s not worth talking about. Want to compare performance of wxPython with Swing? Be prepared to laugh until you pee.