Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Calendar Problem

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


victorsubervi at gmail

Nov 3, 2009, 11:50 AM

Post #1 of 5 (459 views)
Permalink
Calendar Problem

Hi;
I have the following:

import calendar, datetime

myCal = calendar.calendar(6)
today = datetime.date.today()
day = today.day
mo = today.month
yr = today.year
month = myCal.monthdayscalendar(yr, mo)

The last line throws errors no matter how I try and tweak it. The current
incarnation complains about myCal being a string. What do?
TIA,
Victor


klich.michal at gmail

Nov 3, 2009, 12:12 PM

Post #2 of 5 (444 views)
Permalink
Re: Calendar Problem [In reply to]

Dnia wtorek 03 listopada 2009 o 20:50:10 Victor Subervi napisał(a):
> Hi;
> I have the following:
>
> import calendar, datetime
>
> myCal = calendar.calendar(6)
> today = datetime.date.today()
> day = today.day
> mo = today.month
> yr = today.year
> month = myCal.monthdayscalendar(yr, mo)
>
> The last line throws errors no matter how I try and tweak it. The current
> incarnation complains about myCal being a string. What do?
> TIA,
> Victor
>

You should use

myCal = calendar.Calendar(6)

This creates calendar.Calendar object.

--
Michał Klich

klich.michal [at] gmail
michal [at] michalklich
http://www.michalklich.com
--
http://mail.python.org/mailman/listinfo/python-list


davea at ieee

Nov 3, 2009, 3:56 PM

Post #3 of 5 (439 views)
Permalink
Re: Calendar Problem [In reply to]

MichaB Klich wrote:
> Dnia wtorek 03 listopada 2009 o 20:50:10 Victor Subervi napisał(a):
>
>> Hi;
>> I have the following:
>>
>> import calendar, datetime
>>
>> myCal =alendar.calendar(6)
>> today =atetime.date.today()
>> day =oday.day
>> mo =oday.month
>> yr =oday.year
>> month =yCal.monthdayscalendar(yr, mo)
>>
>> The last line throws errors no matter how I try and tweak it. The current
>> incarnation complains about myCal being a string. What do?
>> TIA,
>> Victor
>>
>>
>
> You should use
>
> myCal =calendar.Calendar(6)
>
> This creates calendar.Calendar object.
>
>
Right. But I wanted to tell the OP what to do with an error like this.


You should post the actual error traceback, and tell us what version of
Python you're using:

Traceback (most recent call last):
File "M:\Programming\Python\sources\dummy\stuff2.py", line 15, in <module>
month = myCal.monthdayscalendar(yr, mo)
AttributeError: 'str' object has no attribute 'monthdayscalendar'


Now, since it says that myCal is a 'str' object, the next thing you
should do is look at the value. I get an actual printable calendar for a
year. So clearly, it's not the Calendar object you were looking for. So
you need to change from the calendar() function to the Calendar()
constructor.

DaveA

--
http://mail.python.org/mailman/listinfo/python-list


victorsubervi at gmail

Nov 4, 2009, 7:57 AM

Post #4 of 5 (429 views)
Permalink
Re: Calendar Problem [In reply to]

Well, you're right. That's what I initially had. My server, that I am in the
process of leaving, rejected that syntax. Lovely.
Thanks,
V

On Tue, Nov 3, 2009 at 6:56 PM, Dave Angel <davea [at] ieee> wrote:

>
>
> MichaB Klich wrote:
>
>> Dnia wtorek 03 listopada 2009 o 20:50:10 Victor Subervi napisał(a):
>>
>>
>>> Hi;
>>> I have the following:
>>>
>>> import calendar, datetime
>>>
>>> myCal =alendar.calendar(6)
>>> today =atetime.date.today()
>>> day =oday.day
>>> mo =oday.month
>>> yr =oday.year
>>> month =yCal.monthdayscalendar(yr, mo)
>>>
>>>
>>> The last line throws errors no matter how I try and tweak it. The current
>>> incarnation complains about myCal being a string. What do?
>>> TIA,
>>> Victor
>>>
>>>
>>>
>>
>> You should use
>>
>> myCal =calendar.Calendar(6)
>>
>> This creates calendar.Calendar object.
>>
>>
>>
> Right. But I wanted to tell the OP what to do with an error like this.
>
>
> You should post the actual error traceback, and tell us what version of
> Python you're using:
>
> Traceback (most recent call last):
> File "M:\Programming\Python\sources\dummy\stuff2.py", line 15, in <module>
>
> month = myCal.monthdayscalendar(yr, mo)
> AttributeError: 'str' object has no attribute 'monthdayscalendar'
>
>
> Now, since it says that myCal is a 'str' object, the next thing you should
> do is look at the value. I get an actual printable calendar for a year. So
> clearly, it's not the Calendar object you were looking for. So you need to
> change from the calendar() function to the Calendar() constructor.
>
> DaveA
>
>


carsten.haese at gmail

Nov 4, 2009, 8:35 AM

Post #5 of 5 (418 views)
Permalink
Re: Calendar Problem [In reply to]

Victor Subervi wrote:
> That's what I initially had. My server, that I am in
> the process of leaving, rejected that syntax.

What version of Python does that server use? The calendar.Calendar class
first appeared in Python 2.5. I suspect your server is using an older
version.

--
Carsten Haese
http://informixdb.sourceforge.net

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.