I am curious, what do the 3 different brackets mean in Python programming? Not sure if I\'m correct about this, but please correct me if I\'m wrong:
[] - # No
In addition to Maltysen's answer and for future readers: you can define the []
and ()
operators in a class, by defining the class methods:
()
[]
An example is numpy.mgrid[...]. In this way you can define it on your custom-made objects for any purpose you like.
() parentheses are used for order of operations, or order of evaluation, and are referred to as tuples. [] brackets are used for lists. List contents can be changed, unlike tuple content. {} are used to define a dictionary in a "list" called a literal.
[]
: Used to define mutable data types - lists, list comprehensions and for indexing/lookup/slicing.()
: Define tuples, order of operations, generator expressions, function calls and other syntax.{}
: The two hash table types - dictionaries and sets.