changing a value of a variable

Duncan Booth duncan at NOSPAMrcp.co.uk
Wed Jan 30 04:17:22 EST 2002


"Delaney, Timothy" <tdelaney at avaya.com> wrote in
news:mailman.1012351557.24255.python-list at python.org: 

> The normal method is to rebind the return value of the function to the
> name (in this case, 'n'). The above links will let you understand what
> the previous sentence means.
> 
It is interesting to note that the Pythonic way of doing things (explicitly 
assigning the result to the variables you are changing) makes it far less 
likely that you will make the kind of mistake the original poster made 
where the & was missed out.
Thank goodness for Python.

Before anyone quibbles saying that the compiler would have caught the 
missing &: I have seen C programmers put a cast in to suppress the error 
when the compiler complained about the wrong level of indirection and then 
wonder why they get really obscure crashes.

-- 
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