3 ms·
Can someone please clarify why Python decided to go with unconventional names and symbols? E.g., every other language calls them "arrays", and uses `[ ]`, but
by reactspa 5y ago
Can someone please clarify why Python decided to go with unconventional names and symbols?
E.g., every other language calls them "arrays", and uses `[ ]`, but Python calls (roughly) them "dicts" and uses `{ }`.
Every other language calls them "objects", and uses `{ }`, but Python calls (roughly) them "lists" and uses `[ ]`.
- larrik 5y agoI'm not sure what you mean. An Array is a contiguous section of memory with like items. Those like items _could be_ object pointers. The closest thing in Python to this is a tuple. A List is a collection of things with an order, often a linked list or doubly linked list, but could actually be an array as well. Sometimes "array" and "list" are interchangeable. A Dictionary (aka HashMap) is a key/value store. They are denoted in Python with a bounding {} (similar to like JSON objects). Unlike JS or JSON, the keys can be anything hashable, not just strings or ints. I sort of get the impression that "every other language" means javascript, where we sort of abuse the syntax and treat objects as hashmaps (they aren't really) or arrays (also aren't really). Yet, Python maps quite well against JSON objects and lists. Terminology definitely can be different from language to language, but I find Python to be pretty close to the C class of languages for that.