Harsh
Harsh

Reputation: 115

python AttributeError: 'module' object has no attribute 'monthcalendar'

Here is the code i'm a trying. But Idle gives an Attribute Error. Although calendar is a module in python standard library.

AttributeError: 'module' object has no attribute 'monthcalendar'

The Code:

def main():
   today = datetime.datetime.date(datetime.datetime.now())
   current = re.split('-', str(today))
   current_no = int(current[1])
   current_month = year[current_no-1]
   current_day = int(re.sub('\A0', '', current[2]))
   current_yr = int(current[0])

   print '<h1> %s %s </h1 >' %(current_month, current_yr)

   month = calendar.monthcalendar(current_yr, current_no) 

Upvotes: 0

Views: 2666

Answers (2)

zern
zern

Reputation: 21

Yes. Initially I save it as calendar.py and it displayed the error message, eventually got it fixed by changing the file name.

Upvotes: 0

recursive recursion
recursive recursion

Reputation: 215

The module datetime does of course have an attribute monthcalendar. The only reason I can see for this error is if your file is name "Calendar.py"

Upvotes: 1

Related Questions