The Artima Developer Community
Sponsored Link

Python Buzz Forum
Getting up to date with Python

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Phillip Pearson

Posts: 1083
Nickname: myelin
Registered: Aug, 2003

Phillip Pearson is a Python hacker from New Zealand
Getting up to date with Python Posted: Jun 4, 2007 7:05 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Phillip Pearson.
Original Post: Getting up to date with Python
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
Latest Python Buzz Posts
Latest Python Buzz Posts by Phillip Pearson
Latest Posts From Second p0st

Advertisement

I haven't paid much attention to what's been happening to the Python Programming language since v2.3. Reading through the What's New in Python 2.5 document, though, it looks like they're rounding off a few more of the sharp edges - excellent. A couple of the syntax alterations will save me much code in future. All we need now are convenient anonymous functions, like what you get with function(args) { code } in Javascript, sub { code } in Perl, or { |args| code } in Ruby.

Some highlights:

- with foo(x) as bar: do_something(bar) calls bar.__enter__() before and bar.__exit__() after the do_something(bar) call - similar to C#'s using statement. @contextlib.contextmanager turns generators into classes, so foo(x) can be a function rather than a constructor.

- you can now send data back to an iterator with it.send(value) (which otherwise behaves like it.next()).

- try/except/else/finally can now be used together; no need to nest a try/except block inside a try/finally block.

- the fragile 'a and b or c' syntax now has a Perl/Ruby-like alternative: b if a or c.

- 'http://example.com/'.partition("://") == ('http', '://', 'example.com/')

- startswith/endswith now save you from looping in this common use case: 'foo.jpg'.endswith(('.jpg', 'png', '.gif'))

- defaultdict is a dictionary that provides a default value when you don't supply one. So now instead of mydict = {}; mydict.setdefault(key, []).append(value), you can use mydict = defaultdict(list); mydict[key].append(value)

- msilib lets you create MS Installer .msi files.

- ctypes, which lets you load DLLs / shared libraries and call arbitrary functions in them, is now in the standard distribution.

- ElementTree is now in the standard distribution, as xml.etree.

- new hashlib module: lots o' hashes. md5, sha1, sha{224, 256, 384, 512}.

- sqlite3 is in the standard distribution!

- wsgiref, including basic http server, is now in the standard distribution!

Comment

Read: Getting up to date with Python

Topic: Turbgears Sprint Followup Previous Topic   Next Topic Topic: Jython for Fun and Profit - Sean McGrath

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use