3
class a:
    def __init__(self):
        b
    def c(self):
        d(e)
    def d(self,g):
        print 1

I'm wondering what I should do if I want to use function d in function c as it turns that "global name d is not defined.". Thank you.

2 Answers 2

6

d is an instance method, so you call it using self.d().

Sign up to request clarification or add additional context in comments.

Comments

3

You must call self.d() from your function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.