Python3 Function Not Defined Even Though It Is
Solution 1:
All of the functions you've shown are part of the miscellaneous
class, so to access them, you need to prefix them with the class name. To refer to the getAuthCode
function, you'd use miscellaneous.getAuthCode
.
But, it doesn't seem like you should really be using a class here. You never create instances of miscellaneous
, nor are the functions set up to be run as methods. So, probably the right answer is to get rid of the class miscellaneous:
declaration at the top of the file, and then to unindent all the functions one level.
(Note, in Python 2 you'd have an additional issue if you kept the class: Unbound methods required that their first argument be an instance of their class (or a subclass). In that situation, you'd need to use the staticmethod
decorator on any functions that did not expect to get an instance at all.)
Solution 2:
Functions within a Python class are called methods. They normally take a self
parameter before their other parameters. Furthermore, methods cannot "see" each other directly; you need to call them as self.method(args)
instead of just method(args)
.
Post a Comment for "Python3 Function Not Defined Even Though It Is"