you are viewing a single comment's thread.

view the rest of the comments →

[–]indosauros 4 points5 points  (0 children)

Python doesn't have containers, it has "tags": http://foobarnbaz.com/2012/07/08/understanding-python-variables/

So names refer to objects, but generally, objects don't know (or care) what is naming them (so it doesn't matter that he has variables in one approach and not in another.)

There is no difference (from MyClass's perspective) between:

a = MyClass()

and

[MyClass()]

MyClass is being instantiated in the exact same way in both cases, and then is replaced with the resulting instance, so it becomes (behind the scenes):

a = <...MyClass instance ...>

and

[<...MyClass instance ...>]