[Tutor] using a function and simultaneously accessing an arra y item(?)

Doug Stanfield DOUGS@oceanic.com
Mon, 22 Jan 2001 09:19:48 -1000


Taking it from the inside out:
	mymail.list()	is a method call of an instance of
				a class, presumably returning a list.
	mymail.list()[1]	returns the second element of the list.
	len(mymail.list()[1]) should be the length of that second element

An interesting thing to note is that it isn't acting on the list, but one
element of it.  The length gotten is of that element, not the list.  Also
the list isn't saved for a subsequent use, so if the list() function is
called again and is processor intense this might be an inefficient program.

-Doug-

> -----Original Message-----
> From: cruciatuz [mailto:sasoft@gmx.de]
> Sent: Monday, January 22, 2001 9:00 AM
> To: tutor@python.org
> Subject: [Tutor] using a function and simultaneously 
> accessing an array
> item(?)
> 
> 
> Hello tutor,
> 
>   I found in the python documentation an example
>   for fetching email. there is a snipped of code
>   which i don't understand:
> 
>   numMessages = len(mymail.list()[1])
> 
>   am I accessing the list which is (probably, i
>   don't really know) returned from that function
>   in the same line where I execute the function
>   (or let's say the method)?
> 
>   I just want to be sure about it :)
> 
>   thx in advance.
> 
> + ---------------------------------- +
> | Best regards:   Cruciatuz_AH       |
> + ---------------------------------- +
> | AKA:            Stefan Antoni      |
> + ---------------------------------- +
> | ICQ:            72292815           |
> | PGP-Key:        AVAILABLE          |
> + ---------------------------------- +
> 
> 19:55 / Montag, 22. Januar 2001
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>