'How can I invoke return True or retutrn False from a class function of an external file?
Can I call, thanks to self or something similar, return True or retutrn False from the function of a class of an external file?
I need this because the main file (Page1) needs to know if a result is True or False in order to perform certain operations. For reasons I didn't explain in the question, I need to use self. I don't need to just use return True or return False. The external_class.py file and the main file are related to each other in two ways
I need something like this. Can you help me? Thank you
external_cass.py
class example:
def __init__(self, Page1):
........ (various codes)
def function(self, Page1):
if self.x > int(float(Page1.y.get())):
return self.True #HERE
else:
return self.False #HERE
Solution 1:[1]
In this function, you call prova() but don't do anything with the return value:
def Button1_func(): #HERE I CALL CLASS
k = mediagol.Gol_Mediagol_CF(self) #HERE I CALL CLASS
k.prova(self) #HERE I CALL CLASS
# implicitly returns None
If you want a function to a return a value, return the value.
def Button1_func(): #HERE I CALL CLASS
k = mediagol.Gol_Mediagol_CF(self) #HERE I CALL CLASS
return k.prova(self) #HERE I CALL CLASS
Assuming that Button1_func winds up in the funclist that's used by aaa, it'll now return True or False instead of None when invoked in your all(func() ...) and I expect that'll solve your problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Samwise |
