How does time.localtime() work exactly? I can call up the "array" (tupple, I think it is called - because it is immutable?) and reference/index components of it. For example:
>>> time.localtime()[0]
2010
But if I do:
print time.localtime()
time.struct_time(tm_year=2010, tm_mon=2, tm_mday=7, tm_hour=14, tm_min=46, tm_sec=58, tm_wday=6, tm_yday=38, tm_isdst=0)
First: How does time.localtime() know to return time.struct_time()?
Second: If I type print time.struct_time() it wants additional values to be passed to it (thus not giving me the same values it returned from time.localtime()) - how do I know what those values could possibly be? I checked the python documentation and I couldn't make 'heads nor tails' of it. Really just looking for an example here...
Third: When I index the tupple/array for time.localtime() it returns the proper associated value, "2010" for example, rather than "tm_year=2010" - how does it know to do this (generally speaking not asking for a lot here).
Forth: If I wanted to "call" tm_year from time.localtime() how can I do this? What I am doing (and don't 'feel' right about) is the following:
tm_year = str(time.localtime()[0])
tm_mon = str(time.localtime()[1])
tm_mday = str(time.localtime()[2])
tm_hour = str(time.localtime()[3])
tm_min = str(time.localtime()[4])
NOTE: I am saving them as strings for other reasons not explained in this question, just wanted to point out that I am creating my own variables (named exactly the same as they are in the tupple) and then just referencing the index value associated with the value I want
Is there a way to to just call time.localtime(tm_year) (I know that doesn't work as is, but just brainstorming...)
Thanks in advance... (and I have read "http://docs.python.org/library/time.html" but I am sure I missed some important information... any advice?)
-J