file object: seek and close?

John Roth newsgroups at jhrothjr.com
Thu Sep 18 15:26:18 EDT 2003


"Peter Otten" <__peter__ at web.de> wrote in message
news:bkctm3$34s$05$1 at news.t-online.com...
> Shu-Hsien Sheu wrote:
>
> > Hi,
> >
> > I did some tests and it seems that it was the line that I defined list
> > as a pdbdict0 object was causing the problem.
> >
> > If I remove the line:
> >
> > list = pdbdict0()
> >
>
> This is really strange. I still cannot reproduce the error.
>
> >
> > class pdbdict0(dict):
> >     def __init__(self):
> >         super(dict, self).__init__()
> >         self['header'] = ''
> >         self['compnd'] = []
> >
>
> Wouldn't that be:
>
> class pdbdict0(dict):
>     def __init__(self):
>         super(pdbdict0, self).__init__(self)
>         self['header'] = ''
>         self['compnd'] = []
>
> or better:
>
> def bdbdict0():
>     return {"header": "", "compnd": []}
>
> While the pdbdict0 implementation seems broken, I have no clue what causes
> the file to be closed.
>
> Totally unrelated: Don't use list and type as variable names. They are
> already used as built-in classes.

Actually, that's probably the problem right there. Never, ever use anything
in the built-in namespace as a variable name.

John Roth

>
> Peter






More information about the Python-list mailing list