[Tutor] Through a glass, darkly: the datetime module

Richard D. Moores rdmoores at gmail.com
Sun Oct 7 04:49:37 CEST 2012


On Sat, Oct 6, 2012 at 6:50 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On 07/10/12 12:08, Richard D. Moores wrote:
>>
>> On Sat, Oct 6, 2012 at 4:42 PM, Mark Lawrence<breamoreboy at yahoo.co.uk>
>> wrote:
>>
>>> Use calendar.day_name.
>>
>>
>> How?
>
>
> By reading the Fine Manual.
>
> http://docs.python.org/library/calendar.html#calendar.day_name
>
> which is so short that I can copy it here:
>
> calendar.day_abbr
>     An array that represents the abbreviated days of the week in
>     the current locale.
>
>
> Like other arrays, lists, tuples etc., you use it by getting the
> item at position n:
>
> py> import calendar
> py> calendar.day_name[1]
> 'Tuesday'

Of course, I see now that I'd made a really stupid mistake. I used
parentheses instead of brackets:

>>> import calendar
>>> calendar.day_name(1)
Traceback (most recent call last):
  File "<string>", line 1, in <fragment>
builtins.TypeError: '_localized_day' object is not callable

Thanks,

Dick


More information about the Tutor mailing list