Is it possible to overload the [] operator in python?
I want to access a method of a class by calling classname[elementname] (like in a dict).
This might seem unneccessary but the class encapsulates a database element with children that also have children that also have children that... You get the point.
If I know which child from the 3rd inheritance step I want to get I could then instead of:
classnname.getChild(childname1).getChild(childname2).getChild(childname3)
use the shorter and cleaner:
classnname[childname1][childname2][childname3]
__getitem__Python operator overloadhas the information you seek.__getitem__in that site... Maybe I was looking for the wrong things. Thanks again for your quick help!