Ok, so I looked at some source when I came across this:
>>> def __parse(self, filename): ... "parse ID3v1.0 tags from MP3 file" ... self.clear() ... try: ... fsock = open(filename, "rb", 0) ... try: ... fsock.seek(-128, 2) ... tagdata = fsock.read(128) ... finally: ... fsock.close() ... if tagdata[:3] == 'TAG': ... for tag, (start, end, parseFunc) in self.tagDataMap.items(): ... self[tag] = parseFunc(tagdata[start:end]) ... except IOError: ... pass ...
So, I decided to check it out.
>>> __parse("blah.mp3")
And I got this error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: __parse() takes exactly 2 arguments (1 given)
This is not the first time I have come across this, I always think that I should include self in the argument parameter list, but I know that it is not. Can someone explain to me why this happens so often with the code I'm trying to play with, I believe that because of my level of understanding of the terms, I donβt even understand what init or self is, or why it matters. def x (b): print b is the same as def x (self, b): self.b = b print self.b, right? Why is this so important!
I just want a basic explanation, so I can get it out of my head, thanks.
beginnersluck
source share