[docs] tuple or struct_time

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Jan 3 19:57:30 CET 2011

On Mon, Jan 3, 2011 at 1:40 PM, Georg Brandl <georg at python.org> wrote:
> I don't think so -- the reader may not be aware of that subclass
> relationship, and the repr() of struct_time also doesn't make that
> clear (which is anyway not its job).  It certainly doesn't hurt to
> be a little helpful here.

How far would you go?  We cannot list any possible subclass of tuple:

>>> tm = collections.namedtuple('tm', 'a b c d e f g h i')
>>> time.asctime(tm(*[0]*9))
'Mon Jan  1 00:00:00 2000'

I cannot imagine that someone would want to create a struct_time
instance to pass to time.asctime or time.strftime and it is rather
obvious that these functions should accept what say time.localtime()
produces.  Given that struct_time repr is currently not eval-friendly,
I think the longer a user can get without learning about it, the
happier she will be. :-)

More information about the docs mailing list