is it acceptable to define a function and use it within class? ie
class Forms:
def myform():
do something
def newform():
return myform()
do something else
I am having issues with a piece of code and this seems to work better if i make myform a funtion outside class. Then call it within the newform method. IS this pythonic in any way?
There's nothing wrong with calling another function but your syntax is not correct.
It would look something like
class Forms:
def myform(self):
#do something
def newform(self):
res = self.myform()
#do something else with res
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.