I'm having a problem with the "import promotion" statement in the coffee.py program. Python can't seem to find "promotion" within module transactions. My program follows:
from transactions import *
import promotion
import starbuzz
items = ["DONUT", "LATTE", "FILTER", "MUFFIN", ]
prices = [1.50, 2.20, 1.8, 1.20]
running = True
while running:
option = 1
for choice in items:
print(str(option) + ". " + choice)
option = option + 1
print(str(option) + ". Quit")
choice = int(input("Choose an option: "))
if choice == option:
running = False
else:
credit_card = input("Credit card number: ")
price = promotion.discount(prices[choice - 1])
if input("Starbuzz Card? ") == "Y":
price = starbuzz.discount(price)
save_transaction( new_price, credit_card, items[choice - 1])
The trace back follows:
Traceback (most recent call last):
File "C:\Python32\programs\coffee_pos.py", line 2, in <module>
import promotion
ImportError: No module named promotion
I have reviewed the "transactions" file and it doesn't contain a "promotion" module?
O'Reilly Forums: Chapter 6 Page 211 - O'Reilly Forums
Page 1 of 1
Chapter 6 Page 211 Import promotion question
#2
Posted 26 February 2012 - 03:47 PM
You got it wrong. the promotion Module is a "promotion.py" file to be put in the same directory as your coffee_pos.py. The code it should contain is:
Hope it solves!
def discout (price):
return 0.95 * price
Hope it solves!
Share this topic:
Page 1 of 1


















