0

When I copy the below code in Ideone then it runs fine but it is not running in the text editor and showing the error mentioned in the subject of this post:

import calendar   
c = calendar.TextCalendar(calendar.SUNDAY)
c.prmonth(2007, 7)

The complete error is:

Traceback (most recent call last):
  File "calendar.py", line 1, in <module>
    import calendar   
  File "/home/shl/Desktop/calendar.py", line 2, in <module>
    c = calendar.TextCalendar(calendar.SUNDAY)
AttributeError: 'module' object has no attribute 'TextCalendar'
Sahil Babbar
  • 143
  • 1
  • 2
  • 8
  • Cannot re produce, python 2.7, please add your entire traceback and code. – Kobi K May 14 '14 at 13:24
  • 7
    You named your script `calendar.py`, didn't you? Next time, show a whole traceback. (Also, I have no idea what "running in the text editor" means.) – Wooble May 14 '14 at 13:24

1 Answers1

8

change the program name from calendar.py to something like calendar_code.py

This wold work properly.

Importing from builtin library when module with same name exists

Community
  • 1
  • 1
ravi507
  • 81
  • 1
  • 5