Problem with "open"...

Skip Montanaro skip at
Mon Aug 16 12:37:16 EDT 1999

>>>>> "Michael" == Michael Boyles <mjboyles at> writes:

    Michael> ... and I now get an error from the following code:

    Michael> class effect:
    Michael>   ...
    Michael>   def render():
    Michael>     ...
    Michael>     self.createViewFile("0000.vf")
    Michael>     ...

    Michael>   def createViewFile(self, filename):
    Michael>     f = open(filename, "w")
    Michael>     f.write("rview")
    Michael>     f.close()
    Michael>   ...

    Michael> The error is on the "open" function. It reads:
    Michael>   Exception in Tkinter callback
    Michael>   Traceback (innermost last):
    Michael>   File "/usr/local/lib/python1.5/lib-tk/", line 726, in __call__
    Michael>     return apply(self.func, args)
    Michael>   File "/usr/people/mjboyles/effect/bin/", line 156, in render
    Michael>     self.menuListener.render()
    Michael>   File "", line 423, in render
    Michael>     f = open(("%s.vf" % name), 'w')
    Michael>   TypeError: illegal argument type for built-in operation

    Michael> Any suggestions?

Two things come to mind.  First, the line quoted in the traceback is not the
line you posted as the open call for createViewFile, so it looks like you're
not looking in the correct place for the error.  Second, the error is
probably occurring while evaluating

    "%s.vf" % name

The variable name is not a string.

Skip Montanaro	|
skip at  |

More information about the Python-list mailing list