recommended __future__ imports for 2.5?

J

Joe Strout

OK, this will probably be placed into the "stupid question" category
by some, but I really am in need of a bit of guidance here.

I just rediscovered the "gotcha" of integer division in 2.5 and below,
and found (to my delight) that this is fixed in 3.0, and fixable in
older versions of Python with "from __future__ import division". Once
I stumbled across that, I was able to find the relevant PEP (#238) and
read more about it. So now that import has become part of our
standard boilerplate at the top of each file, along with the path to
Python and the UTF-8 encoding declaration.

Now I'm wondering what other boilerplate I should be using. I'm not
yet ready to upgrade to Python 2.6 -- parts of our business model rely
on using the standard Python installed with Mac OS X (which is
currently 2.5.1). But I would like our code to be as future-proof as
possible, especially in cases like this where we're talking about
changes to existing behavior, rather than the introduction of entirely
new features (like the "with" statement).

I found <http://www.python.org/doc/2.5.2/ref/future.html>, which lists
the available future imports, but doesn't link to any documentation on
them. Searching for each one on google turns up some probably-
relevant PEPs, but it's hard for a relative newbie to tell for sure
exactly what was implemented when and which is merely a summary of
discussion.

So... besides "division", are there any other imports you would
recommend as standard for any new code written in 2.5? And what else
do you experienced gurus put at the top of every Python file?

Thanks,
- Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top