question on the 'calendar' function

Ben Finney ben+python at benfinney.id.au
Tue Nov 20 13:07:22 EST 2018


o1bigtenor <o1bigtenor at gmail.com> writes:

> I am in the process of learning my first computer programming language
> (unless g-code counts and then it is my second - - - grin). It
> definitely is a big world out there.

Welcome, and congratulations on starting with Python!

> The calendar function has a lot of versatility and shows care in its
> development.

I assume we are here talking about the standard library ‘calendar’
module <URL:https://docs.python.org/3/library/calendar.html>, and the
function is ‘calendar.calendar’ to generate a whole year calendar
<URL:https://docs.python.org/3/library/calendar.html#calendar.calendar>.

> For planning I need to be able to easily look backward 6 months and
> forward at least 12 and better 18 months and would prefer perhaps even
> a total of 36 (and even 60 might be useful) months of calendar
> available. It could be useful to see the longer time spans as weeks
> rather than as days but seeing the larger time frames only as months
> would enable the planning that I need to do.

Have you looked through the rest of the documentation of that module?
Does ‘calendar.monthcalendar’ come close to what you need
<URL:https://docs.python.org/3/library/calendar.html#calendar.monthcalendar>?

> Do I need to (somehow and I have no idea how) extend the calendar
> function?

It's quite feasible you may get to that point, at which time you will
want to learn about composing functions by calling other functions;
eventually you will learn a different technique, of creating a class by
inheriting from an existing class.

But all that may be in the future! Try just using the existing functions
from that library module and see how far that gets you.

Good hunting.

-- 
 \         “I have the simplest tastes. I am always satisfied with the |
  `\    best.” —Oscar Wilde, quoted in _Chicago Brothers of the Book_, |
_o__)                                                             1917 |
Ben Finney




More information about the Python-list mailing list