Simon Willison’s Weblog

Subscribe
Atom feed for python

1,060 items tagged “python”

The Python programming language.

2003

Accessible Python

A post on Bryan Richard’s blog about Safari leads to a query about whether or not Py (a Python print magazine) should move to PDF, which in turn leads to a fascinating discussion about the accessibility of both websites and Python source code itself. Well worth taking the time to read.

Useful python resources

A bunch of useful Python resources:

[... 68 words]

Python and micropayments

Fredrik Lundh has started posting his book The Standard Python Library online, in response to O’Reilly’s decision not to publish a second edition of the book. I’d never read it before, but having sampled the first two chapters I’m hooked. It works a bit like a “cookbook”, with a plethora of code samples explained in detail accompanied by tips and tricks relating to the language. The Lazy Import class, which loads a module only when an attribute of the module is called for the first time, is a classic example:

[... 209 words]

Python power

Sam Ruby’s ultra-simple 3-paned aggregator is a great example of the power of high level scripting languages. Using the wxPython cross-platform GUI toolkit and Mark Pilgrim’s ultra-liberal RSS Parser it provides a full application in a mere 107 lines of (highly readable and maintainable) code.

[... 127 words]

Python for Java programmers

Python and Jelly: Scripting Power for Java and XML incorporates an excellent introduction to Python and Jython for Java programmers, with a whole bunch of comparative code samples and comprehensive coverage of differences between the two languages.

More Python advocacy

Intelligent Enterprise: For all of you unfamiliar with Python, get ready for the “next big thing.”

Python bits and bobs

Two fun bits from the Daily Python URL today (still without permalinks). SQLObject is an object-relational mapper class which can create objects that directly map to rows in a relational database, making INSERTs and UPDATEs much simpler. I’ve tried to write this kind of thing in PHP before with mixed results, so I’m quite tempted to pinch the idea of tracking foreign keys and joins for my next attempt. More immediately useful however is rlcompleter2 which adds tab based auto completion to the Python interactive prompt. I had a play with it earlier and it was definitely an improvement on the vanilla command line.

Dynamic Python class methods

Dynamically extending APIs: Mark Pilgrim demonstrates how Python’s “new” module can be used to dynamically add new methods to existing classes at run time, and shows how this can be used to increase productivity when parsing XML. I’ve long been impressed with Python’s ability to add new methods to an object at runtime just by assigning a function reference to an object property but I had no idea it was possible to do this with classes as well. If you liked that tip, Dive Into Python has in depth explanations of more obscure Python features than you can shake a stick at.

Python path module

The path Python module (via The Daily Python-URL) is a nice looking wrapper class for Python’s oft-confusing os.path module. Check out this neat code comparison:

[... 103 words]

Pythonology

Pythonology (via Deadly Bloody Serious about Python) is a Python advocacy site aimed at software engineers and managers. The site has a fantastic collection of case studies, Python Success Stories, which an interesting piece describing why and how Rackspace migrated their main enterprise data system from PHP to Python.

First deployment of Vellum

Oooh... Stuart has moved his blog over to Vellum, his brand new sparkly Python powered blogging system. The full post is here, but his archive / permalinks aren’t working yet. It’s going to be fun watching the system develop.

The making of Python

One for the reading list: The Making of Python—A conversation with Guido van Rossum, Part I.

2002

Python as middleware

OpenEnterpriseTrends.com: Python Power: Growing Respect for an Open Source Integration Tool. Another excellent piece of Python advocacy, this time highlighting Python’s power and flexibility as a middleware tool to glue together varous large enterprise systems.

Object persistence

Simon Brunning talks about persistence, and how much more complicated it is now that objects are involved. The best explanation I’ve seen of how objects and relational databases can be used together was in Martin Fowler’s Patterns of Enterprise Application Architecture, but now that the book has been published he has removed the online version. IBM’s DeveloperWorks has a new article up describing persistence management in Python, which talks in details about Python’s native serialization method (pickling) but only mentions ZODB in passing. I agree with Simon—object databases just don’t seem as elegant a solution as RDBMSs. Object databases may provide persistence but they don’t seem nearly as powerful as relational databases when it comes to flexibility of accessing data.

Linux Gazette Python articles

Linux Gazette has a couple of interesting Python articles at the moment. Dealing with User Input in Python is a beginners guide to validating user input, while Pl/Python and Cursors in Pl/Pgsql for PostgreSQL explains how Python can be used to write stored procedures in PostgreSQL.

PythonCard scriptlets

Kevin Altis on scripting applications written in PythonCard:

[... 334 words]

Python e-mail features

Python 2.2.2 is out. It’s mostly bug fixes, but they have also included the latest version of the Python email package. I’ve been playing with Python’s email features recently as part of an experimental idea to import all of my mail (from various accounts) in to a mySQL database and build my own web mail / mail application program. Working with email in Python is beautfully simple, thanks to the aforementioned email package and the powerful pop3 and IMAP classes in the standard library.

mod_python donated to the ASF

mod_python has been donated to the Apache Software Foundation. This is excellent news—I have always been slightly wary of mod_python as it has a reputation for being unstable, but with the ASF directly supporting it hopefully any stability problems will soon be a thing of the past.

effnews part two

Fetching and Parsing RSS Data is the second installment of the effnews project, a series of tutorials on creating an RSS news reader in Python. This time topics covered include exception handling and event based XML parsing using xmllib.

[... 122 words]

Python RSS tutorials

Spotted on Python owns us: Fredrik Lundh is building an RSS newsreader in Python, and writing Python tutorials on the project as he goes along. The first tutorial, Fetching RSS Files, is available now and covers (in detail) retrieving RSS files over the web, including an excellent explanation of asynchronous HTTP requests.

DevShed stuff

DevShed have published two useful new articles—MySQL Connectivity With Python and Understanding SQL Joins. They also now provide nice looking printer-friendly PDF versions of articles, which appear to be dynamically generated. Having found this article on Google I suspect they are using HTMLDOC to create the PDFs.

Python RSS locator

Mark Pilgrim has written an ultra-liberal RSS locator (in Python, naturally). I guess he had to scratch an itch. The amount of work it puts in to locating an RSS feed for a site is astonishing, especially when you consider how short the actual code is.

Another free Python book

How to Think Like a Computer Scientist: Learning with Python is a new Python text book covered by the GNU Free Documentation License and available on the web. The thread discussing it on Slashdot gives mixed reviews, with other recommended free alternatives including Mark Pilgrim’s Dive Into Python and Thinking in Python by Bruce Eckel.

Windows SSL support in Python

Adding SSL support to Python on Windows is as easy as dropping a couple of DLLs and a .pyd file in to your Python DLLs directory. Grab the zip file from this page and off you go. I haven’t tried it out yet but it appears to work—the socket.ssl function miraculously appeared when I installed the new files. Why is this useful? Because it opens the way for secure XML-RPC calls from Python applications...

PythonCard and PyCrust

Patrick O’Brien: Building GUI Applications with PythonCard and PyCrust. I’m a big fan of PythonCard, an excellent toolkit for creating GUI applications in Python that seperates the GUI layout from the program logic and makes it ridiculously easy to put together a basic GUI in a short space of time. Patrick is the developer of PyCrust, an interactive shell for debugging and interacting with GUI components, and is also a contributor to PythonCard as a whole. Patrick and Kevin Altis, the lead developer of PythonCard, will be presenting a session on PythonCard at OSCON on Thursday.

Pimping opportunity

Tip off for Stuart: The new Python Wiki includes an index of available web frameworks, but there’s no mention of Castalian yet.

Addition to the blogroll

Small Values of Coollinks to things that I find interesting by Simon Brunning. I turns out I find them interesting as well. Lots of Python stuff on there at the moment, including a link to the new Python Wiki.

Fun with Amazon

There’s plenty of activity surrounding Amazon web services today. My limited demo barely scratches the surface of the possibilities—people are already experimenting with Amazon’s similarity search and Mark Pilgrim has released PyAmazon, a Python wrapper for the Amazon API. I’ve started listing alternative implementations on the PHP Amazon Search page, and I’ll be sure to blog the more innovative examples as and when I find them.

Python in PHP

Python in PHP (via HarryF on the SitePoint Forums):

[... 123 words]

xmlhack news wire

xmlhack’s “Editor’s Newswire” is interesting. It is a small column (explained here) located on the right hand side of the site that displays the latest XML news snippets “in real time”. The interesting part is how the section is updated—an IRC bot (The Daily Chump Bot, written in Python) monitors a channel for specific commands from authorised users, and produces an XML file of new snippets. Site updates through IRC (or instant messenging services such as MSN or Jabber) is a concept which we could see a lot more of, especially in this age of web services.