Taking this class as an example:
class MyClass(object):
def __init__(self):
self.attribute = 4
def my_method(self):
def my_fun(arg1, arg2):
self.attribute = 7
pass
should my_fun be allowed to access and change self.attribute ?
I can see that my editor does not colour self inside my_fun.
This is what I am trying to implement: my_method should call an external function that requires a callback taking two arguments, arg1 and arg2. I would like to extend the functionality by allowing this callback to use variables declared inside my_method, and also make the my_fun callback write some debugging info to self.log. I am not quite sure if this is the right design for this type of problem.
my_fun(val1,val2)insidemy_method. try playing around withmy_methodand actually run it a few timesselfidentifier, which is referencing the instance, (if called as a method on an instance)