Re: Newbie question, list comprehension

2008-06-08 Thread Mark Wooding
Johannes Bauer <[EMAIL PROTECTED]> wrote: > import time > localtime = time.localtime(1234567890) > fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % (localtime[0], localtime[1], > localtime[2], localtime[3], localtime[4], localtime[5]) > print fmttime > > fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % ([l

Re: Newbie question, list comprehension

2008-06-07 Thread Larry Bates
Johannes Bauer wrote: Hello group, I'm currently doing something like this: import time localtime = time.localtime(1234567890) fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % (localtime[0], localtime[1], localtime[2], localtime[3], localtime[4], localtime[5]) print fmttime For the third line the

Re: Newbie question, list comprehension

2008-06-06 Thread Johannes Bauer
Hans Nowak schrieb: In this case, you can just use a slice, as localtime is a tuple: fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % localtime[:6] Hope this helps! ^_^ Ahh, how cool! That's *exactly* what I meant with "awesome Python magic" :-) Amazing language, I have to admit. Regards, J

Re: Newbie question, list comprehension

2008-06-06 Thread Hans Nowak
Johannes Bauer wrote: Hello group, I'm currently doing something like this: import time localtime = time.localtime(1234567890) fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % (localtime[0], localtime[1], localtime[2], localtime[3], localtime[4], localtime[5]) print fmttime For the third line the

Newbie question, list comprehension

2008-06-06 Thread Johannes Bauer
Hello group, I'm currently doing something like this: import time localtime = time.localtime(1234567890) fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % (localtime[0], localtime[1], localtime[2], localtime[3], localtime[4], localtime[5]) print fmttime For the third line there is, I suppose, some