Python Forum

Full Version: Difference () and []
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to know whats the difference in:
something()
and
something[]
something() applies to objects having a __call__() method and it executes this method, while something[] applies to objects having a __getitem__() method and it executes this method.
Examples of the two cases mentioned by Gribouillis are functions in the former case and lists/dictionaries/tuples in the latter.
Also consider braces {}. A good source to see what you use when is the docs at Python Docs