another newbie question

O

otenki

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
 
P

Peter Otten

otenki said:
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:
0.5
 
D

David

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.
 
O

otenki

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
 
R

Roy Smith

David said:
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.
 
M

MRAB

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...
 
N

Neil Cerutti

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.
 
A

Anssi Saari

Roy Smith said:
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).
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top