Skip to content

Tag: methods

Way to call method depending on variable?

I already have a working, but in my oppinion not beautiful solution for a part of a long script. My script uses several similar methods, that differ too much to combine. However I came to a point where I want to call one of those methods depending on a given variable. The names of the methods are build up lik…

How to get instance given a method of the instance?

Now can you get a reference to myInstance if you now only have access to methodReference? Answer If you are using Python 3: Otherwise: and by a similar token, for the class: For this kind of code discovery you should install iPython and use tab, for instance, in your case myReference.+TAB would give: Hence, y…