[Python-Dev] File Object Copy

Guido van Rossum guido@beopen.com
Wed, 12 Jul 2000 08:21:18 -0500

> > footnote: it's definitely an accepted pydiom:
> Yes, but one I personally do not like
> > aifc.py:
> >         if type(f) == type(''):
> >             f = __builtin__.open(f, 'rb')
> > etc.
> > 
> > it's a reasonable way to make your code a bit more reusable
> > (it's rude to expect every chunk of potentially usable data to
> > have a filename...).
> Of course -- that's why I think most code should use file-like objects.

Agreed.  The quoted examples are all kludges in my book.  (The API
designer initially accepted only a filename, then realized this was a
bad choice, and fixed it in a backwards compatible way instead of
fixing it right.  There are just as many examples where it's done
right, I just can't think of any. :-)

--Guido van Rossum (home page: http://dinsdale.python.org/~guido/)