Returning a tuple-struct
timr at probo.com
Sun Jan 22 07:52:01 CET 2006
groups.20.thebriguy at spamgourmet.com wrote:
>I've noticed that there's a few functions that return what appears to
>be a tuple, but that also has attributes for each item in the tuple.
>For example, time.localtime() returns a time.time_struct, which looks
>like a tuple but also like a struct. That is, I can do:
>(2006, 1, 18, 21, 15, 11, 2, 18, 0)
Ah, but it ISN'T really a tuple:
>>> import time
>>> t = time.localtime()
'(2006, 1, 21, 22, 49, 32, 5, 21, 0)'
It's a class object. The __repr__ method returns a string that LOOKS the
same as a tuple.
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list