News for hackers. Stuff that matters.
Re:Ask YC: Best practice for Python module imports? by njm on Sunday June 14, 2009 @05:51PM (#657597)
My rule of thumb: I only import things locally (i.e. within a function) if it is a conditional dependency. This is particularly true if it's something not from the standard library. Example: I might have an application that supports multiple database back ends, such as PostgreSQL, SQLite, etc, but I'll conditionally import only the one applicable DB API module.

There are no comments on this comment yet.