[Tutor] "TypeError: open, argument 1: expected string, file found"

David Jansen djansen@pobox.com
Tue, 4 Jul 2000 14:22:26 +0900

Mr. Gauld and everyone else on the list,

I am sure someone can offer a quick solution to this one...

I am working my way through the last half of Alan Gauld's "Case Study"
section in his Learning to Program tutorial and I am having a problem with
the document module. I've posted my slightly altered version at the address


When I try to run it I get the following error:

>>> Traceback (innermost last):
  File "C:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\Python\document.py", line 124, in ?
    D = HTMLDocument(file)
  File "D:\Python\document.py", line 12, in __init__
    self.infile = open(filename, "r")
TypeError: open, argument 1: expected string, file found

If you see any other problems I am going to run into, I would of course
appreciate the head's up.

Thank you in advance,

David Jansen
Tsukuba, Japan