Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > another newbie question

Reply
Thread Tools

another newbie question

 
 
otenki
Guest
Posts: n/a
 
      11-14-2010
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
 
Reply With Quote
 
 
 
 
Tim Golden
Guest
Posts: n/a
 
      11-14-2010
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
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      11-14-2010
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

 
Reply With Quote
 
David
Guest
Posts: n/a
 
      11-14-2010
On 15/11/2010, otenki <(E-Mail Removed)> 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.
 
Reply With Quote
 
otenki
Guest
Posts: n/a
 
      11-14-2010
On Nov 14, 10:09*am, David <(E-Mail Removed)> wrote:
> On 15/11/2010, otenki <(E-Mail Removed)> 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
 
Reply With Quote
 
Roy Smith
Guest
Posts: n/a
 
      11-14-2010
In article <(E-Mail Removed)>,
David <(E-Mail Removed)> wrote:

> On 15/11/2010, otenki <(E-Mail Removed)> 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.
 
Reply With Quote
 
MRAB
Guest
Posts: n/a
 
      11-14-2010
On 14/11/2010 16:40, Roy Smith wrote:
> In article<(E-Mail Removed)>,
> David<(E-Mail Removed)> wrote:
>
>> On 15/11/2010, otenki<(E-Mail Removed)> 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...
 
Reply With Quote
 
Neil Cerutti
Guest
Posts: n/a
 
      11-15-2010
On 2010-11-14, Roy Smith <(E-Mail Removed)> 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
 
Reply With Quote
 
Anssi Saari
Guest
Posts: n/a
 
      11-20-2010
Roy Smith <(E-Mail Removed)> 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).
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another basic question: How to call and show one Web Form from another Web Form? Rob R. Ainscough ASP .Net Web Controls 3 06-14-2005 03:56 PM
another newbie question from another newbie.... Lee UK VOIP 4 05-17-2005 04:10 PM
Another newbie question re: STDERR and IPC::open3(), nowait() and zombies Dave Newberry Perl 0 10-17-2004 06:41 PM
dumb newbie question (or newbie dumb question) Jerry C. Perl Misc 8 11-23-2003 04:11 AM
another newbie question about vhdl Max VHDL 2 09-01-2003 03:07 PM



Advertisments