My own list object
Remco Gerlich
scarblac at pino.selwerd.nl
Wed Feb 6 12:04:28 EST 2002
MDK <mdk at mdk.com> wrote in comp.lang.python:
> I made a file mylist.py
>
> # mylist.py
> class MyList:
> def __init__(self):
> self.list=[]
> def append(self, item):
> self.list.append(item)
>
> >>> import mylist
> >>> x = mylist()
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> TypeError: object of type 'module' is not call
>
> Why is this happening? My list object must be a class in its own,
> importable file.
'mylist' is a module. 'mylist.MyList' is the class you defined in the module.
So x = mylist.MyList() is what you meant.
--
Remco Gerlich
More information about the Python-list
mailing list