Mailing List Archive

Problem with "open"...
I am a very new user to python, but I thought I picked it up pretty
quickly. The code I have been using has been working for several
months now. I recently reorganized the modules (placement in the .py
file) and renamed some variables (nothing fancy) and I now get an
error from the following code:


class effect:
...

def render():
...
self.createViewFile("0000.vf")
...

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

...


The error is on the "open" function. It reads:

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


Any suggestions? I have no idea about the error. When I try the
function during regular interperator mode from the prompt, it works
fine. Is there a description about the possible python errors
somewhere?

Thanks in advance...
- Mike
___________________________________________________
_/ \_
| Michael Boyles Research Programmer |
| Advanced Visualization Lab Indiana University |
|_ mjboyles@iupui.edu www.vrve.iupui.edu/~mjboyles _|
\___________________________________________________/
Problem with "open"... [ In reply to ]
>>>>> "Michael" == Michael Boyles <mjboyles@voyager.vrve.iupui.edu> 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/Tkinter.py", line 726, in __call__
Michael> return apply(self.func, args)
Michael> File "/usr/people/mjboyles/effect/bin/effectGUI.py", line 156, in render
Michael> self.menuListener.render()
Michael> File "effect.py", 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 | http://www.mojam.com/
skip@mojam.com | http://www.musi-cal.com/~skip/
847-971-7098