Forgetting "()" when calling methods

Duncan Booth duncan at NOSPAMrcp.co.uk
Mon Apr 28 05:32:41 EDT 2003


Lulu of the Lotus-Eaters <mertz at gnosis.cx> wrote in 
news:mailman.1051497463.22158.python-list at python.org:

> And to be even trickier, answer the question for the following lists:
> 
>     [u'x', 'x', chr(255)].sort()
>     ['x', chr(255), u'x'].sort()
>     [1j, '1', 1].sort()
>     [1, 1j, '1'].sort()
> 
> 
> Then try to explain the answer to ANYONE you know.

I must admit I was surprised that 3 of these failed to sort, since I'd 
guessed that you would have selected 2 that worked and 2 that failed. So my 
question is, did one of the last two actually work on your system?

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list