[reportlab-users] isinstance(val, file)

Andy Robinson andy at reportlab.com
Wed Nov 14 16:16:11 EST 2007


On 14/11/2007, Carl Karsten <carl at personnelware.com> wrote:

> 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:



The traditional python approach would be...

if hasattr(val, 'file'):
#treat it like a file
else:
#treat it like a string

i.e. if it walks like a duck and quacks like a duck...

- Andy


More information about the reportlab-users mailing list