[reportlab-users] isinstance(val, file)
Carl Karsten
carl at personnelware.com
Wed Nov 14 08:35:25 EST 2007
This is not really a reportlab problem, but close enough.
How can I test that the file to be passed to canvas.Canvas(buffer) is really a
file type object that can be written to? I am trying to work with a wrapper
that looks like this:
val = StringIO()
...
if isinstance(val, file) or True:
self._outputFile = val
else:
s = os.path.split(val)
...
p = canvas.Canvas(val)
Val isn't a file, so it hits the else and blows.
I could check for isinstance(val,str) but was would feel better if there was a
sure fire way to verify that what was going to be passed to canvas.Canvas(val)
was going to work.
Carl K
More information about the reportlab-users
mailing list