Steven D'Aprano <[EMAIL PROTECTED]> wrote:
...
> What do people think about functions that accept either a file name or a
> file object?
>
> def handle_file(obj):
> if type(obj) == str:
> need_to_close = True
> obj = file(obj, 'r')
> else:
> need_to_close = Fals
Steven D'Aprano wrote:
On Fri, 04 May 2007 07:55:25 -0700, Alex Martelli wrote:
What about the case where I have an array of objects that represent some
particular binary file format. If the object is a file, then I want to
copy its contents. If the object is a string, th
Steven D'Aprano wrote:
>
> What do people think about functions that accept either a file name or a
> file object?
>
>
> def handle_file(obj):
> if type(obj) == str:
> need_to_close = True
> obj = file(obj, 'r')
> else:
> need_to_close = False
> do_something_with