[Tutor] Getting error that calendar is underfined when importing
calendar module
Vicki Stanfield
vicki at stanfield.net
Wed Mar 23 19:06:59 CET 2005
Hi all. I am using Python 2.4 on a Slackware Linux box and am having a
problem importing the calendar module into a program that I am writing.
The code is simple and looks like this:
import cgitb, os, sys
cgitb.enable()
sys.strerr = sys.stdout
import cgi
import time
import calendar
print "Content-Type: text/html\n\n"
print
print "<html><head></head><body>\n\n"
#Get date variables
from datetime import datetime
date = datetime.now().date()
today= date.strftime("%m %Y")
thisyear = date.strftime("%Y")
thismonth = date.strftime("%m")
#Print calendar for the current month
calendar.prmonth(int(thisyear),int(thismonth))
---------
For some reason that I don't understand, I get an error when I use this
code in a cgi way (run the file out of cgi-bin) but not when I type it
from the command line. The error I get is this:
/var/www/cgi-bin/calendar.py
43 calendar.prmonth(int(thisyear),int(thismonth))
calendar = <module 'calendar' from '/var/www/cgi-bin/calendar.py'>,
calendar.prmonth undefined, builtin int = <type 'int'>, thisyear = '2005',
thismonth = '03'
AttributeError: 'module' object has no attribute 'prmonth'
args = ("'module' object has no attribute 'prmonth'",)
The calendar module description says there is a prmonth, and as I said, it
works from the command line. Can anyone tell me what I am missing?
Vicki
More information about the Tutor
mailing list