Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jamesapp

macrumors 6502a
Original poster
Mar 7, 2008
544
0
working on a python programming book.
in the book there is a section on numbers. One numeric type according to the book was introduced with Python 2.4, it is the decimal object. In the book they are using the interactive Python prompt and they say to type the following:
Code:
decimal.Decimal(1) / decimal.Decimal(7)
and in the book they show there answer:
Decimal("0.142857...etc.")
earlier in the book they say to import, the code that is needed to work with Decimals
by including the following code at the interactive prompt:
Code:
from decimal import Decimal
when i go to run the code from the book i get the following error from my Python interactive prompt:
Code:
>>> decimal.Decimal(1) / decimal.Decimal(7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'decimal' is not defined
any help?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.