Calendar Problem

View: New views
5 Messages — Rating Filter:   Alert me  

Calendar Problem

by Victor Subervi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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

Re: Calendar Problem

by Bugzilla from klich.michal@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
michal@...
http://www.michalklich.com
--
http://mail.python.org/mailman/listinfo/python-list

Re: Calendar Problem

by Dave Angel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



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

Re: Calendar Problem

by Victor Subervi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...> 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



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

Re: Calendar Problem

by Carsten Haese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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