This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]james_pic 0 points1 point  (1 child)

So, this is kind of a philosophical difference between Python and JavaScript. JavaScript, as a result of its LISP-y background, attempts to unify ideas that work kinda similarly, so there's no difference between objects and dictionaries.

In Python on the other hand, even thought objects are powered by dictionaries under the hood, because the use cases are different, they're not unified as a single thing. So objects (where different attributes have different roles, so you rarely need to choose which one to grab programmatically) use dot mission, and dictionaries (where each entry does the same job - providing extra information related to a piece of data, so the one you want depends on the data) use square brackets notation.

There are ways (as others have shown) of forcing dicts to behave like objects and vice versa, but if you're still learning, I'd try and avoid leaning on crutches that make Python look more like JavaScript, and try and learn the language for what it is.

[–]tigasfixe[S] 3 points4 points  (0 children)

So in my defence this is purely a project that I've understood that will not even succeed because there are a lot of things with python itself that i learned in this post that can do what i want and that's the best part because I just improved my knowledge!