Python Forum

Full Version: Displaying a calendar
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been trying to display a calendar month using Python3.6 and whilst the code works perfect from the command-line it only produces a list of errors if i try to display from a file in Atom text editor. Hope someone can help please.

#!/usr/bin/env python3.6 

# import module
import calendar

yy = 2018
mm = 11

# To ask month and year from the user
# yy = int(input("Enter year: "))
# mm = int(input("Enter month: "))

# display the calendar
print(calendar.month(yy, mm))
(Jul-08-2018, 10:06 AM)oldDog Wrote: [ -> ]it only produces a list of errors if i try to display from a file in Atom text editor.
Please, always post full traceback, in error tags
Hi buran
This is the code i have been using:

#!/usr/bin/env python3.6 

# import module
import calendar

yy = 2018
mm = 11

# To ask month and year from the user
# yy = int(input("Enter year: "))
# mm = int(input("Enter month: "))

# display the calendar
print(calendar.month(yy, mm))
And this is the output.

oldD@my-desktop-ubuntu-mate:~$ python3 ~/my_python3/calendar.py
Traceback (most recent call last):
  File "/home/oldDog/my_python3/calendar.py", line 6, in <module>
    import calendar
  File "/home/oldDog/my_python3/calendar.py", line 15, in <module>
    print(calendar.month(yy, mm))
AttributeError: 'function' object has no attribute 'month'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
    from urllib.request import urlopen
  File "/usr/lib/python3.6/urllib/request.py", line 88, in <module>
    import http.client
  File "/usr/lib/python3.6/http/client.py", line 71, in <module>
    import email.parser
  File "/usr/lib/python3.6/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "/usr/lib/python3.6/email/feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "/usr/lib/python3.6/email/_policybase.py", line 9, in <module>
    from email.utils import _has_surrogates
  File "/usr/lib/python3.6/email/utils.py", line 33, in <module>
    from email._parseaddr import quote
  File "/usr/lib/python3.6/email/_parseaddr.py", line 16, in <module>
    import time, calendar
  File "/home/oldDog/my_python3/calendar.py", line 15, in <module>
    print(calendar.month(yy, mm))
AttributeError: 'function' object has no attribute 'month'

Original exception was:
Traceback (most recent call last):
  File "/home/oldDog/my_python3/calendar.py", line 6, in <module>
    import calendar
  File "/home/oldDog/my_python3/calendar.py", line 15, in <module>
    print(calendar.month(yy, mm))
AttributeError: 'function' object has no attribute 'month'
oldDog@my-desktop-ubuntu-mate:~$
Big thanks for any and all help
Rename calendar.py(what calendar use) to eg my_calender.py.