another newbie question

Discussion in 'Python' started by otenki, Nov 14, 2010.

  1. otenki

    otenki Guest

    Hello Pythonistas!
    I'm trying to get floating point division to work; I'm using Python
    2.6.5. When I enter 'from _future_ import division' at the command
    line, I get the ImportError, no module named _future_. How can I
    rectify this?
    Sorry for this basic question, but I don't know where else to turn.
    Thanks,
    Scott
    otenki, Nov 14, 2010
    #1
    1. Advertising

  2. otenki

    Tim Golden Guest

    On 14/11/2010 3:00 PM, Nitin Pawar wrote:
    >> I'm trying to get floating point division to work; I'm using Python
    >> 2.6.5. When I enter 'from _future_ import division' at the command
    >> line, I get the ImportError, no module named _future_. How can I
    >> rectify this?


    That should be two underscores, not one:

    from __future__ import division

    TJG
    Tim Golden, Nov 14, 2010
    #2
    1. Advertising

  3. otenki

    Peter Otten Guest

    otenki wrote:

    > Hello Pythonistas!
    > I'm trying to get floating point division to work; I'm using Python
    > 2.6.5. When I enter 'from _future_ import division' at the command
    > line, I get the ImportError, no module named _future_. How can I
    > rectify this?


    You need two leading/trailing underscores, not one:

    >>> 1/2

    0
    >>> from __future__ import division
    >>> 1/2

    0.5
    Peter Otten, Nov 14, 2010
    #3
  4. otenki

    David Guest

    On 15/11/2010, otenki <> wrote:
    > When I enter 'from _future_ import division' at the command
    > line, I get the ImportError, no module named _future_.


    The module name is "__future__"

    Notice that there are 2 underscore characters before the word "future"
    and 2 after it. This is a common convention in python.
    David, Nov 14, 2010
    #4
  5. otenki

    otenki Guest

    On Nov 14, 10:09 am, David <> wrote:
    > On 15/11/2010, otenki <> wrote:
    >
    > > When I enter 'from _future_ import division' at the command
    > > line, I get the ImportError, no module named _future_.

    >
    > The module name is "__future__"
    >
    > Notice that there are 2 underscore characters before the word "future"
    > and 2 after it. This is a common convention in python.


    Thanks to all for your quick responses to my newbie question. It is
    much appreciated!!!
    Scott
    otenki, Nov 14, 2010
    #5
  6. otenki

    Roy Smith Guest

    In article <>,
    David <> wrote:

    > On 15/11/2010, otenki <> wrote:
    > > When I enter 'from _future_ import division' at the command
    > > line, I get the ImportError, no module named _future_.

    >
    > The module name is "__future__"
    >
    > Notice that there are 2 underscore characters before the word "future"
    > and 2 after it. This is a common convention in python.


    I suppose the double-underscore convention was a questionable choice,
    given how many fixed width fonts make it difficult to discern the gap
    between them. In fact, in most fonts, it's an intentional design goal
    that they run together (think of it as a sort of recurisive ligature).
    That being said, it is what it is, and isn't changing.

    I'm really picky about what font I use for coding. For years, I've
    stuck to Apple's Monaco, antialised. In the latest version of the OS
    (Snow Leopard), they added a new font called Menio. When I first looked
    at it, I couldn't tell the difference, and decided to stick with Monaco.
    I just opened up TextEdit and tried looking at __ (double underscore) in
    various fonts. Lo and behold, you can see the gap in Monaco, and the
    two run completely together in Menio.

    I'm still searching for as nice a font to use on Linux.

    Then, there are people who try to program in proportional fonts. The
    mind boggles. For a (thankfully short) while some years ago, people
    were publishing programming books with the code samples in proportional
    fonts. Blech.
    Roy Smith, Nov 14, 2010
    #6
  7. otenki

    MRAB Guest

    On 14/11/2010 16:40, Roy Smith wrote:
    > In article<>,
    > David<> wrote:
    >
    >> On 15/11/2010, otenki<> wrote:
    >>> When I enter 'from _future_ import division' at the command
    >>> line, I get the ImportError, no module named _future_.

    >>
    >> The module name is "__future__"
    >>
    >> Notice that there are 2 underscore characters before the word "future"
    >> and 2 after it. This is a common convention in python.

    >
    > I suppose the double-underscore convention was a questionable choice,
    > given how many fixed width fonts make it difficult to discern the gap
    > between them. In fact, in most fonts, it's an intentional design goal
    > that they run together (think of it as a sort of recurisive ligature).
    > That being said, it is what it is, and isn't changing.
    >

    [snip]
    Guido chose double underscores because CPython is written in C and
    that's what C uses. It's true that with hindsight it was a mistake...
    MRAB, Nov 14, 2010
    #7
  8. otenki

    Neil Cerutti Guest

    On 2010-11-14, Roy Smith <> wrote:
    > Then, there are people who try to program in proportional
    > fonts. The mind boggles. For a (thankfully short) while some
    > years ago, people were publishing programming books with the
    > code samples in proportional fonts. Blech.


    I kinda like it, but as a Vim user I can't partake.

    --
    Neil Cerutti
    Neil Cerutti, Nov 15, 2010
    #8
  9. otenki

    Anssi Saari Guest

    Roy Smith <> writes:

    > I'm still searching for as nice a font to use on Linux.


    Envy Code R is a lookalike, so maybe worth considering. I haven't
    tried actual Monaco on Linux, but apparently it's possible.
    Personally, I use -lfp-gamow-medium-r-*-*-7-*-*-*-*-*-*-* in Linux
    (Emacs).
    Anssi Saari, Nov 20, 2010
    #9
    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. Max
    Replies:
    2
    Views:
    455
    Ralf Hildebrandt
    Sep 1, 2003
  2. Dave Newberry
    Replies:
    0
    Views:
    647
    Dave Newberry
    Oct 17, 2004
  3. SStory
    Replies:
    1
    Views:
    291
    Kevin Spencer
    Aug 4, 2003
  4. Rob R. Ainscough
    Replies:
    3
    Views:
    322
    Rob R. Ainscough
    Jun 14, 2005
  5. Jerry C.
    Replies:
    8
    Views:
    229
    Uri Guttman
    Nov 23, 2003
Loading...

Share This Page