On 02/24/2013 06:04 PM, Steven D'Aprano wrote: > Variables do not have types in Python. > > Reset your thinking. Python is a dynamic language with name bindings and > strongly-typed objects, not a static language with strongly-typed > variables. If you don't understand the difference, ask. But so long as > you make the wrong assumptions about the language, you will have a bad > time.
Yes, but according to my computer language theory class, strictly speaking, python has no variables, only names and objects, which for the most part aren't mutable. A variable by definition is a box in memory that you can write to. The closest thing python has to that are instances of mutable types like a list. "a=5" certainly doesn't allocate a box in memory somewhere and stick 5 in it. And then later "a += 1" or "a=6" doesn't mutate the value stored in the box represented by a. Instead it allocates a new object and makes a refer to that new object. I know all this is what you meant, but with the original poster's frustrations with python, it's important that he just throw out the notion of variations entirely because sooner or later that will get him in trouble here, like if he tries to make an empty list be a default value for a function parameter. -- http://mail.python.org/mailman/listinfo/python-list