I have a weird problem. I have a function that is supposed to returns list. I call the function using an object called 'common' and found that it returns None always (common.reset_this). But when I define this function outside the class, it returns what it is supposed to return. Is there anything I am missing here.
class something_else():
//
...
//
def reset_this(self,unit = 0):
with self.__reset_lock:
status = self.get_status(unit)
return status
Assuming it's not a typo you're missing the self argument to your method, you need:
class something_else():
#
# ...
#
def reset_this(self, unit = 0):
with common.__reset_lock:
status = common.get_status(unit)
return status
Without it unit is getting passed the self object (as opposed to 0) because python doesn't care what you call it, the first argument is always the "self" object (the object the method is being called on).
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.