recommended __future__ imports for 2.5?

Discussion in 'Python' started by Joe Strout, Nov 24, 2008.

  1. Joe Strout

    Joe Strout Guest

    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
     
    Joe Strout, Nov 24, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Logan
    Replies:
    3
    Views:
    817
    Michael Hudson
    Nov 25, 2003
  2. Malcolm Greene
    Replies:
    1
    Views:
    398
    Dan Bishop
    Apr 12, 2008
  3. Albert
    Replies:
    4
    Views:
    11,028
    Albert
    Jul 10, 2008
  4. zildjohn01
    Replies:
    0
    Views:
    685
    zildjohn01
    Feb 22, 2011
  5. Victor Hooi
    Replies:
    1
    Views:
    128
    Devin Jeanpierre
    Nov 25, 2013
Loading...

Share This Page