Simon Willison’s Weblog

Subscribe

Items tagged python in Oct, 2010

Filters: Year: 2010 × Month: Oct × python × Sorted by date


Is there a blog that covers open source Python projects?

No, but I wish there was.

[... 29 words]

Why does Python load imported modules separately for different files, unlike C or PHP? Isn’t that inefficient in terms of memory usage?

It doesn’t—you’re misunderstanding how Python’s module system works. If two different places have “import os” in them, the os module is only imported and executed once—it’s cached in the sys.modules dictionary so you can see it happen if you want to. The key thing to understand is that “import os” attaches the os module to the “os” symbol within the current file’s scope, loading it only if it hasn’t been loaded already.

[... 104 words]

What’s a good book about basic usage techniques and patterns in Python? (a la Effective Java/C++)

Dive into Python 3 is well worth a look: http://diveintopython3.org/

[... 48 words]

Bleach, HTML sanitizer and auto-linker. HTML sanitisation is notoriously difficult to do correctly, but Bleach (a Python library) looks like an excellent effort. It uses the html5lib parsing library to deal with potentially malformed HTML, uses a whitelist rather than a blacklist and has a neat feature for auto-linking URLs that is aware of the DOM (so it won’t try to auto-link a URL that is already wrapped in a link element). It was written by the Mozilla team for addons.mozilla.org and support.mozilla.org so it should be production ready. # 25th October 2010, 1:32 pm

What does the key word “yield” in Python do?

The best documentation I’ve seen on generators is this: http://www.dabeaz.com/generators/

[... 26 words]

Who are the best Python developers in Los Angeles?

Mahalo is based in Santa Monica, and they have a very talented team of Python/Django people. They also host a regular Django meetup: http://www.meetup.com/ladjango/

[... 40 words]

What are some tips for a new Python developer coming from C++/Java?

Read “Python is not Java” from 2004—it has some good tips on how working with the two languages differs.

[... 41 words]

Is the complexity of basic Python data structure operations documented?

Python’s C code has some excellent documentation, including detailed write-ups of how Python’s dictionary and sorting algorithms work. They’re a great read.

[... 42 words]

What’s the easiest way to take an existing Django view and make it “real time” via long polling?

I’d advocate decoupling your long polling endpoints entirely from the rest of your web app stack. Personally I like Node.js for this, but Tornado would work just fine too (I’ve experimented successfully with Tornado long polling in the past).

[... 171 words]

I think that “bad technology” can kill a startup, but slightly different variations of good technology don’t have much effect. Choose what you know/like best. And Ruby and Python are both in this latter category.

enko on Hacker News # 2nd October 2010, 11:19 am

Types

Years

Months

Tags