I\'m writing some code that takes a filename, opens the file, and parses out some data. I\'d like to do this in a class. The following code works:
class MyCl
Call the function in this way:
self.parse_file()
You also need to define your parse_file() function like this:
def parse_file(self):
The parse_file
method has to be bound to an object upon calling it (because it's not a static method). This is done by calling the function on an instance of the object, in your case the instance is self
.