time, calendar, datetime, etc

John Roth newsgroups at jhrothjr.com
Thu Jul 31 14:03:10 CEST 2003


"Ben S" <bens at replytothegroupplease.com> wrote in message
news:bgaphh$lua$1 at news7.svr.pol.co.uk...
> Steven Taschuk wrote:
> > Quoth Kylotan:
> >   [...]
> >> And does datetime.timetuple() actually return something equivalent to
> >> a struct_time as used by the time module? At first glance this looks
> >> to be true, but it isn't clearly documented as such.
> >
> > Isn't it?
> >
> >     timetuple()
> >         Return a 9-element tuple of the form returned by
> > time.localtime().
> >
> > <http://www.python.org/doc/current/lib/datetime-datetime.html>
>
> Problem is, time.localtime() doesn't return a 9-element tuple any more,
> it returns a struct_time. (Since 2.2, I think.)

Strictly speaking, that's true, but the object that's returned
*acts* like a sequence of 9 integers if you reference it properly.
It seems like 2.2 did this in a number of places, so that you
could reference values by name. I like the thinking behind it.
It's a lot better documentation if you want to get one value at
a time.

John Roth

>
> --
> Ben Sizer
> http://pages.eidosnet.co.uk/kylotan
>
>






More information about the Python-list mailing list