tuple or struct_time
Functions in the time module that expect broken down time are currently documented as accepting "tuple or struct_time". For example, http://docs.python.org/py3k/library/time.html#time.strftime However, in recent versions, ".. or struct_time" is redundant because
issubclass(time.struct_time, tuple) True
I think it would be more informative for a reader to change "tuple or struct_time" to "9-tuple".
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 03.01.2011 19:35, schrieb Alexander Belopolsky:
Functions in the time module that expect broken down time are currently documented as accepting "tuple or struct_time". For example,
http://docs.python.org/py3k/library/time.html#time.strftime
However, in recent versions, ".. or struct_time" is redundant because
issubclass(time.struct_time, tuple) True
I think it would be more informative for a reader to change "tuple or struct_time" to "9-tuple".
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. Georg -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEYEARECAAYFAk0iGCMACgkQN9GcIYhpnLDmKQCePKov8SmLcA1zs1TXXiBNqD+O A1oAnie+elSLWddJK4HYVx0M9hL2tP0j =MjyU -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 03.01.2011 19:40, schrieb Georg Brandl:
Am 03.01.2011 19:35, schrieb Alexander Belopolsky:
Functions in the time module that expect broken down time are currently documented as accepting "tuple or struct_time". For example,
However, in recent versions, ".. or struct_time" is redundant because
issubclass(time.struct_time, tuple) True
I think it would be more informative for a reader to change "tuple or struct_time" to "9-tuple".
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.
Ah -- changing tuple to 9-tuple is fine of course. Georg -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEUEARECAAYFAk0iGEwACgkQN9GcIYhpnLBizwCglhL2y1DrZzGoucxxjv9/vOFi 8eIAmPuPwKfwEOHdBBGnBTEF8sQtGQI= =mYM5 -----END PGP SIGNATURE-----
On Mon, Jan 3, 2011 at 1:40 PM, Georg Brandl <georg@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. :-)
participants (2)
-
Alexander Belopolsky
-
Georg Brandl