how to return a StringIO of an Image
Bengt Richter
bokr at oz.net
Fri Nov 14 18:28:17 EST 2003
On Fri, 14 Nov 2003 20:38:43 +0000 (UTC), JCM <joshway_without_spam at myway.com> wrote:
>Bengt Richter <bokr at oz.net> wrote:
>> On Fri, 14 Nov 2003 16:45:39 +0100, "Fredrik Lundh" <fredrik at pythonware.com> wrote:
>
>>>"Christoph" wrote:
>>>
>>>> image.save('test', 'JPEG')
>>>> image=StringIO(image.????()) # what's the right method?
>>>> return image
>>>>
>>>> Any hints? Thanx!
>>>
>>> file = StringIO()
>>> image.save(file, "JPEG")
>>> return file.getvalue()
>>>
>> You are recommending shadowing 'file' ?!
>
>Why not? Python is a block-structured language. New builtins can
>arrive in any release.
I'd say a reason is to avoid the time you will do it by habit and get a surprise.
But yes, there's no technical reason you can't, if you don't want to use the original
binding in that scope.
Regards,
Bengt Richter
More information about the Python-list
mailing list