| re: PIL: how to return a StringIO of an Image
On Fri, 14 Nov 2003 20:38:43 +0000 (UTC), JCM <joshway_without_spam@myway.com> wrote:
[color=blue]
>Bengt Richter <bokr@oz.net> wrote:[color=green]
>> On Fri, 14 Nov 2003 16:45:39 +0100, "Fredrik Lundh" <fredrik@pythonware.com> wrote:[/color]
>[color=green][color=darkred]
>>>"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()
>>>[/color]
>> You are recommending shadowing 'file' ?![/color]
>
>Why not? Python is a block-structured language. New builtins can
>arrive in any release.[/color]
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 |