Python scoping
Chris Angelico
rosuav at gmail.com
Mon Jun 20 20:55:55 EDT 2011
More information about the Python-list mailing list
Mon Jun 20 20:55:55 EDT 2011
- Previous message (by thread): Python scoping
- Next message (by thread): Python scoping
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Jun 21, 2011 at 10:39 AM, Ben Finney <ben+python at benfinney.id.au> wrote: > gervaz <gervaz at gmail.com> writes: > Python doesn't have variables the way C or many other languages have > them. > > Instead, Python has objects, and references to those objects so you can > get at them. The Python documentation, much to my frustration, calls > these references “variables” even though that gives exactly the wrong > implication of how they'd behave. But variable names in C and variable names in Python follow fairly similar rules. Yes, there's the whole thing of automatic sharing and automatic deallocation, but the name still follows rules of scoping that are very similar - but more flexible in C. > With the assignment statements (the statements using ‘txt = …’), the > name ‘txt’ is bound as a reference to a value. It's not a C-like > variable; it doesn't have a type, it doesn't need to be declared, etc. > It's just a name, that you can bind to exactly one value any time you > like. It does have a type. It's a Python object. That data type can hold any one "thing". :) ChrisA
- Previous message (by thread): Python scoping
- Next message (by thread): Python scoping
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list