New variable?

Lie Lie.1296 at gmail.com
Sun Jun 8 02:08:38 EDT 2008


On Jun 4, 1:40 am, tmallen <thomasmal... at gmail.com> wrote:
> What's the proper way to instantiate a new variable? x = ""?

You don't need to. The reason why you need to "declare" variable when
doing something like a += 1 is because this is actually a shorthand
for a = a + 1 (unless you override __radd__), the a on the right-hand
side is not yet assigned to any objects (remember that python use the
"name tag" model instead of "variable" model).



More information about the Python-list mailing list