Ah Python, you have spoiled me for all other languages
Marko Rauhamaa
marko at pacujo.net
Fri May 22 16:34:47 EDT 2015
Ian Kelly <ian.g.kelly at gmail.com>:
> An "object" in Javascript is basically just a collection of
> properties. For example:
>
> js> typeof([1, 2, 3])
> "object"
> js> typeof({a: 1, b: 2, c: 3})
> "object"
>
> Here's what happens when you try to access a property on null:
>
> js> null.foo
> typein:18:0 TypeError: null has no properties
That's not all that different from Python, where object() returns a
fresh instance at each invocation. However:
>>> object().x = 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'x'
Why are object instances immutable in Python?
Marko
More information about the Python-list
mailing list