Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×

Python 2.5 Released 228

dominator writes "It's been nearly 20 months since the last major release of the Python programming language, and version 2.5 is probably the most significant new release of Python since 2.2. The latest release includes a variety of additions to the standard library, language extensions, and performance optimizations. This is a final release, and should be suitable for production use. Read the release announcement, the highlights, what's new, and download it."
This discussion has been archived. No new comments can be posted.

Python 2.5 Released

Comments Filter:
  • Python Challenge (Score:5, Informative)

    by Franio ( 964631 ) on Tuesday September 19, 2006 @01:59PM (#16139230)

    I know this is offtopic but does anyone know what happened to the python challenge [pythonchallenge.com]?

    There have been no new levels for a long time.

    For those who haven't seen it, the python challenge is a great way to learn python.

    • The python challenge is a great way to learn any language period.

      Solve it once, then try to solve it again in any language you try to learn, since it's a very practical "hands on" excercise, it makes discovering and learning a language much more interresting and rewarding.

  • Any recommended resources for starting out on Python?

    I'm surprised that was never taught at the local community college since the computer department dean started the Unix Administration class this semester with a story about killing a rattle snake at his home in the country. With the end of the shotgun less than two inches away from the snake's head, there wasn't too much left to worry about bees getting into the venom.
    • The O'Reilly "learning python" book is good if you've already got a little (only a tiny amount needed) background in a language. Even shell scripting is good enough. It's pretty dense, so you have to accept that as part and parcel of it, but it's solid.

      Otherwise, http://www.ibiblio.org/obp/thinkCSpy/ [ibiblio.org] is as good as many and better than most.
    • Re: (Score:3, Informative)

      by Anonymous Coward
      Dive Into Python [diveintopython.org] really helped me to get started. You can buy it as a book, but it's also available for free on the web. Guido's own tutorial [python.org] is also a good way to get started, as python's creator wrote it himself, and is a pretty good teacher too. Both of these are no big secret, but both are well written and clear, so i'd check them out first before looking for more detailed tutorials. Python's official documentation/website are really so good that looking elsewhere is for the most part unnecessary.
    • Tip #1: I highly recommend adding pyrepl to your Python environment. It enhances functionality of the interactive interpreter such that you can easily edit multi-line code snippets. Forward and back (control-n, control-p) through history. Control-r (then start typing) to find something back in history. Very useful. http://codespeak.net/pyrepl/ [codespeak.net]

      Tip #2: Avail yourself of the help() function in the interpreter. help(SomeObjectOrFunction) i.e. help(open) will return the docstrings associated; help(SomeModule) i.
    • Re: (Score:2, Informative)

      by All_Star25 ( 736597 )
      I have been tutoring a 7th or 8th-grader in Python for several months now using the book How to Think Like a Computer Scientist: Learning with Python [ibiblio.org]. It's released for free under the GFDL, and I printed up two copies of it via PrintFu, and it seems to be a pretty good text. However, it's primarily geared towards those with no prior programming experience. Regardless, I learned the language along with him as I tutored, and learned some general programming things from the book. I have no idea to what ext
    • learning (Score:2, Informative)

      by mackyrae ( 999347 )
      I'm using a book called Python Programming for the Absolute Beginner. It explains all the data types and stuff which does get a little annoying if you already know another programming language, but it cost $15 less than Dive Into Python. I think one of the guys in my dorm is going to borrow it because he needs those explanations (first language).
    • If you 'invest' in a book, make sure that it covers at least python 2.2 ... You don't want a 1.6x book which will leave you in the dark about new style classes, scoping rules etc. (ie. if you get the O'Reilly Learning Python [oreilly.com] book, make sure it is 2nd Ed.)

      Having said that I'm going to totally contradict myself by pointing you in the direction of Instant Python [hetland.org]. (Actually I'm warning you that this is out of date, it's just such a quick hand up that it's still worth a look at.) More generally a list of on-

  • Sqlite included! (Score:4, Informative)

    by imag0 ( 605684 ) on Tuesday September 19, 2006 @02:03PM (#16139255) Homepage
    From TFA:

    In keeping with the theme of adding tried and true packages to the standard library, in 2.5 we've added ctypes, ElementTree, hashlib, sqlite3 and wsgiref to the standard library that ships with Python.

    That made me sit up and take notice. A pretty nice programming language with built-in functionality to read and write Sqlite databases natively?

    Looks like they release a Mac installer, too. Think I'll have to check it out when I get home

    Cheers
  • by gd2shoe ( 747932 ) on Tuesday September 19, 2006 @02:06PM (#16139279) Journal
    Although not as elegant as:
    cout << ( a==b ? "first option" : "second option" )
    It is good to finally see inline conditions such as:
    print ( "first option" if a==b else "second option" )
    This just makes me happy! ;-)
    • Re: (Score:2, Insightful)

      by xquark ( 649804 )
      I believe this new inline conditional is just plain ugly!

      When developing computer language syntax, natural language
      imitation should not be the priority - also being different
      for the sake of being different is so very early 90s.

      • Re: (Score:2, Redundant)

        Indeed, I got puzzled about the choice for this syntax.

        They explain why, whether one agrees or not with it, in this part of the release notes [python.org].

        In short, there was some discussion on the mailing lists about whether the syntax should be, and no clear winner could be appointed. Then, the BDFL figured out that whenever conditional expressions are used, one of the values is usually the norm and the other the exception, thus, putting the normal value at the beggning of the expression made it for code readability.

        F
      • Re: (Score:2, Insightful)

        by the_wesman ( 106427 )
        "When developing computer language syntax, natural language imitation should not be the priority"

        I could care less about inline if statements - I assume that those are only for people who either are the dangerous kind of lazy, like to write hard-to-read code or don't use emacs

        in response to your 'natural language' comment, I'm hoping that isn't the reason that this was done because the if/else syntax we already have imitates natural language.

        If she is hot, hit on her. else, if she is not hot and I'm drunk h
        • Re: (Score:2, Insightful)

          by Haeleth ( 414428 )
          If she is hot, hit on her. else, if she is not hot and I'm drunk hit on her. else go home.

          looks like natural language to me.


          Looks rather unnatural to me. The usual way to say it would be more like "Hit on her if she's hot or you're drunk, else go home."

          Which, I realised as I typed it, is exactly how Python's new inline conditional syntax works. Neat.
  • Finally! Of course they have the most bass-ackward possible syntax, but at least they're there.
  • by ttfkam ( 37064 ) on Tuesday September 19, 2006 @02:42PM (#16139587) Homepage Journal
    Would someone be so kind as to explain this construct for me?
    try:
        block-1 ...
    except Exception1:
        handler-1 ...
    except Exception2:
        handler-2 ...
    else:
        else-block
    finally:
        final-block
    Coming from Java and C++ land, I'm familiar with the idea of

    try {} catch (...) {} finally {}

    What is the point of else? What does it get you that you didn't have just as easily without it? If no exception is thrown, run it? Isn't that what the content in the try section is for? Will someone provide a use case for this for me please?
    • by artlogic ( 819675 ) on Tuesday September 19, 2006 @02:51PM (#16139658) Homepage
      You would include logic in the else to be executed in the case that no exceptions occur, that is:

      else:
          print "no exceptions occured!"

      Everything else is the same as Java/C++.
      • by truedfx ( 802492 )
        So basically,
        try:
        a
        except:
        b
        else:
        c
        is the same as
        try:
        rethrow = False
        a
        rethrow = True
        c
        except:
        if rethrow:
        raise
        b
        except without an extra variable? (I'm not sure how to make /. respect the spacing, sorry for that.)
    • by masklinn ( 823351 ) <.slashdot.org. .at. .masklinn.net.> on Tuesday September 19, 2006 @02:56PM (#16139696)

      The code that you run after the part you may want to protect could thrown an exception that you wouldn't want to catch in your except handlers.

      The else clause gives you a way to run it without the risk of shadowing/accidentaly catching these exceptions.

    • I'm interested to know what would happen if you 'return' from the ELSE block, but have code in the FINALLY block.

      foo = 42
      try:
      print "a"
      except:
      print "b"
      else:
      print "c"
      return foo
      finally:
      foo = 13
      print "d"

      What would this actually do? Would it save the value of 'foo' as 42, run the FINALLY block, and then return the saved value? Or would it actually modify the value to return, hence return 13? Or would it just crash?
      • I'm interested to know what would happen if you 'return' from the ELSE block, but have code in the FINALLY block.
        See The return statement [python.org] First, the exception passed to 'return' is evaluated (in your example to 42), then the 'finally' block is executed. So, this function prints "a","c","d" and returns 42.
  • WxPython (Score:5, Informative)

    by nih ( 411096 ) on Tuesday September 19, 2006 @02:55PM (#16139681)
    anyone using wxpython will need to upgrade to wxpython for python 2.5

    http://www.wxpython.org/download.php [wxpython.org]

    as soon as i'd installed python 2.5 all my app died, took me a few mins
    to realise that py2.5 breaks wxpython for py2.4, and some tk demo's ran:)
  • Glad to see ElementTree's gone into the main Python distribution - it's a very nice way of working with XML, and the one I generally use if I have the choice (IMO it has a nice, clean, Pythonic API which generally fits with what I want to do, though it does require you to load the entire XML tree into memory before you do anything with it).
  • I've been using Python in Pails for about 3 months now and absolutely love it. It's the only Web 2.0 compliant framework I use for dynamic database driven website creation. It's flexible too, unlike some other tools that ascribe to the one size fits all mentality (PHP we're looking at you). Pails let's you choose a thimble (small framework) for your small customer websites or a full blown pail for your enterprise sites. I'm looking forward to getting wrapped up in this new version of Python, but I can't

The Tao is like a glob pattern: used but never used up. It is like the extern void: filled with infinite possibilities.

Working...