Movatterモバイル変換
[0]ホーム
[Python-Dev] time functions
M.-A. Lemburgmal@lemburg.com
Tue, 16 Jan 2001 11:18:44 +0100
Thomas Wouters wrote:>> Maybe this is a dead and buried subject, but I'm going to try anyway, since> everyone's been in such a wonderful 'lets fix ugly but harmless nits' mood> lately :)>> Why do we need the following atrocity <wink>:>> timestr = time.strftime("<format>", time.localtime(time.time()))>> To do the simple task of 'date +<format>' ? I never really understood why> there isn't a way to get a timetuple directly from C, rather than converting> a float that we got from C a bytecode before, even though the higher level> almost always deals with timetuples. How about making the float-to-tuple> functions (time.localtime, time.gmtime) accept 0 arguments as well, and> defaulting to time.time() in that case ? Even better, how about doing the> same for the other functions, too ? (where it makes sense, of course :)>> Actually, I'll split it up in three proposals:>> - Making the time in time.strftime default to 'now', so that the above> becomes the ever so slightly confusing:>> timestr = time.strftime("<format>")> (confusing because it looks a bit like a regexp constructor...)>> - Making the time in time.asctime and time.ctime optional, defaulting to> 'now', so you can just call 'time.ctime()' without having to pass> time.time() (which are about half the calls in my own code :)>> - Making the time in time.localtime and time.gmtime default to 'now'.>> I'm 0/+1/+1 myself :)+1 all the way -- though these days I tend not to use thetime module anymore. mxDateTime already does everything I wantand there date/time values are objects rather than Python integersor tuples... ok, I'm just showing opff a little :)-- Marc-Andre Lemburg______________________________________________________________________Company:http://www.egenix.com/Consulting:http://www.lemburg.com/Python Pages:http://www.lemburg.com/python/
[8]ページ先頭