I'm faint why this can't work
JStoneGT at aol.com
JStoneGT at aol.com
Fri Feb 16 01:38:43 EST 2007
Hello,
I got this similar sample script from books:
$ cat sampdict.py
#!/usr/bin/python
class SampDict(dict):
def __init__(self, filename=None):
self["name"] = filename
But when I run it I got the errors:
>>> from sampdict import SampDict
>>> SampDict("/etc/passwd")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "sampdict.py", line 4, in __init__
self["name"] = filename
AttributeError: SampDict instance has no attribute '__setitem__'
I'm using Python 2.3.4.
Please help.Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070216/177d9c9d/attachment.html>
More information about the Python-list
mailing list