Variable Scope 2 -- Thanks for 1.
Duncan Booth
me at privacy.net
Sat Jan 10 07:14:35 EST 2004
More information about the Python-list mailing list
Sat Jan 10 07:14:35 EST 2004
- Previous message (by thread): Variable Scope 2 -- Thanks for 1.
- Next message (by thread): Variable Scope 2 -- Thanks for 1.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
JCM <joshway_without_spam at myway.com> wrote in news:btn6ks$ada$1 at fred.mathworks.com: > Irmen de Jong <irmen at -nospam-removethis-xs4all.nl> wrote: > ... >> A very important concept with Python is that you don't have variable >> assignment, but name binding. An "assignment statement" binds a name >> on an object, and the object can be of any type. A statement like >> this: > >> age = 29 > >> doesn't assign the value 29 to the variable age. Rather, it labels >> the integer object 29 with the name age. > > I think this statement is misleading--it seems to imply the integer > object is altered somehow. Personally I see no problem with saying > the value 29 is assigned to the variable age, so long as you > understand the semantics. > Be careful. The integer object is actually altered, at least in so far as its reference count (which is part of the object) is changed: >>> import sys >>> sys.getrefcount(29) 11 >>> age = 29 >>> sys.getrefcount(29) 12 >>> -- Duncan Booth duncan.booth at suttoncourtenay.org.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?
- Previous message (by thread): Variable Scope 2 -- Thanks for 1.
- Next message (by thread): Variable Scope 2 -- Thanks for 1.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list