My code is skipping inner function | Selenium Python Forum
A
Ajaypal Gill Posted on 26/04/2020
'''
Created on Apr 25, 2020

@author: ajgill
'''

def smartD(func):
    def inner(self):
        global a
        global b
        #self.a = a
        #self.b = b
        if(self.b==0):
            print("Dude, you are doing something wrong")
            quit()
        return func(self)
    return inner
        
class Decor:   
    a= input("Enter First num: ")
    b= input("Enter Second Num: ")
    @smartD
    def add (self):
        global a
        global b
        c= int (self.a)/int (self.b)
        print(c)
d=Decor()
d.add()

0
09914040666 Replied on 28/04/2020

Hey Ajaypal, 

Please try this :

def smartD(func):
def inner(self,b):
print("Dividing two numbers ",a, " and ",b)
if(b==0):
print("Dude, you are doing something wrong")
quit()

return func(self,b)
return inner

a= input("Enter First num: ")
# b= input("Enter Second num: ")

class Decor:
global a,b
@smartD
def div(self,b):
c= int(a)/b
print("Output is : "+str(c))

d=Decor()
d.div(0)


Related Posts