Re: Returning a tuple-struct



groups.20.thebriguy@xxxxxxxxxxxxxxx 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:
>
>>>> time.localtime()
>(2006, 1, 18, 21, 15, 11, 2, 18, 0)
>>>> time.localtime()[3]
>21
>>>> time.localtime().tm_hour
>21

Ah, but it ISN'T really a tuple:

>>> import time
>>> t = time.localtime()
>>> type(t)
<type 'time.struct_time'>
>>> str(t)
'(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@xxxxxxxxx
Providenza & Boekelheide, Inc.
.



Relevant Pages

  • Re: Class to Class data transfer
    ... - Tim Roberts, timr@xxxxxxxxx ... Providenza & Boekelheide, Inc. ... Prev by Date: ...
    (microsoft.public.vc.language)
  • Re: nasm-question: get linear address
    ... - Tim Roberts, timr@xxxxxxxxx ... Providenza & Boekelheide, Inc. ... Prev by Date: ...
    (comp.lang.asm.x86)
  • Re: USB Camera Filter Driver
    ... how the IRP_KS_READ_STREAM ioctl works. ... Tim Roberts, timr@xxxxxxxxx ... Providenza & Boekelheide, Inc. ...
    (microsoft.public.development.device.drivers)
  • Re: a question about "return"
    ... Some people include one for completeness -- a coding standard ... Tim Roberts, timr@xxxxxxxxx ... Providenza & Boekelheide, Inc. ...
    (comp.lang.python)
  • Re: Question about sizeof
    ... - Tim Roberts, timr@xxxxxxxxx ... Providenza & Boekelheide, Inc. ... Prev by Date: ...
    (microsoft.public.win32.programmer.kernel)