[Tutor] using a function and simultaneously accessing an arr

Sean 'Shaleh' Perry shaleh@valinux.com
Mon, 22 Jan 2001 11:31:57 -0800 (PST)


On 22-Jan-2001 cruciatuz wrote:
> 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 :)
> 

certainly looks that way.  What you are doing is treating the function call as
a reference to the variable it returns.  I personally would not write code like
this.  You have no way to catch errors (what if it could not read your mail?). 
it is also confusing unless you are carefully reading.