Trying to understand a very simple class - from the book "dive into python"
walterbyrd at iname.com
Wed May 20 17:52:56 CEST 2009
Example 5.6. Coding the FileInfo Class
"store file metadata"
def __init__(self, filename=None):
self["name"] = filename (2)
What I do not understand is the last line. I thought 'self' was
supposed to refer to an instance of the object. But the square
brackets seem to indicate a list. Except you can not assign values to
a list like that. So where does "name" come from?
I am sure this is totally simple, but I missing something.
More information about the Python-list