Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function calls function in python

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.

like image 444
Michael Avatar asked Jul 19 '26 10:07

Michael


1 Answers

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

like image 69
Blender Avatar answered Jul 20 '26 23:07

Blender



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!