En Mon, 12 May 2008 06:45:40 -0300, Michele Simionato <[EMAIL PROTECTED]> escribió: > On May 12, 4:28 am, Yves Dorfsman <[EMAIL PROTECTED]> wrote: >> there's got to be a better way than: >> >> d = time.local() >> y = d[0] >> d = d[1] > > Uses Python 2.6! ;) > > Python 2.6a3 (r26a3:62861, May 12 2008, 11:41:56) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import time >>>> time.localtime() > time.struct_time(tm_year=2008, tm_mon=5, tm_mday=12, tm_hour=11, > tm_min=43, tm_sec=47, tm_wday=0, tm_yday=133, tm_isdst=1) >>>> t=time.localtime() >>>> t.tm_year, t.tm_mday > (2008, 12)
No need of 2.6 - the above code works since Python 2.2 at least: Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> t=time.localtime() >>> type(t) <type 'time.struct_time'> >>> t.tm_year 2008 (but struct_time objects were printed as regular tuples) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list