A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2000-July/006203.html below:

[Python-Dev] File Object Copy

[Python-Dev] File Object CopyFredrik Lundh Fredrik Lundh" <effbot@telia.com
Wed, 12 Jul 2000 11:04:27 +0200
moshe wrote:
> > >   1. It would be easy to skip the open and close operations in=20
> > >      'shutil.copyfile', if either 'src' or 'dst' are already open=20
> > >      file objects instead of strings. =20
> >=20
> > -0: Too much Perl-like DWIM magic

footnote: it's definitely an accepted pydiom:

aifc.py:
        if type(f) =3D=3D type(''):
            f =3D __builtin__.open(f, 'rb')

binhex.py:
        if type(ofp) =3D=3D type(''):
            ofname =3D ofp
            ofp =3D open(ofname, 'w')

mimify.py:
 if type(infile) =3D=3D type(''):
  ifile =3D open(infile)

pstats.py:
  elif type(arg) =3D=3D type(""):
   f =3D open(arg, '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...).

</F>




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4