Reputation: 39
When I call func1 from func2, I get an error. Why is this occurring and how to access the returned dictionary d in func1 from func2?
func1() NameError: name 'func1' is not defined
class ABC():
def func1(self, a):
d = {}
###do something with a
###return ending dictionary d
return d
def func2(self):
###Retrieve returned dictionary d from func1 and use
func1()
d['key'] = value
Upvotes: 0
Views: 29
Reputation: 7971
func1 and func2 are instance methods of ABC objects. You need to call them from the instance of such object.
In your case, one such instance is self
, first parameter of both functions.
Thus, self.func1()
will work.
Upvotes: 2