[Python-Dev] File Object Copy
Greg Stein
gstein@lyra.org
Wed, 12 Jul 2000 01:43:38 -0700
On Wed, Jul 12, 2000 at 10:21:08AM +0300, Moshe Zadka wrote:
> On Wed, 12 Jul 2000, Peter Funk wrote:
> > 'shutil.copyfile' however takes filenames as arguments and contains
> > the loop sketched above as inline code. I see two possibilities:
> > 1. It would be easy to skip the open and close operations in
> > 'shutil.copyfile', if either 'src' or 'dst' are already open
> > file objects instead of strings.
>
> -0: Too much Perl-like DWIM magic
>
> > 2. Or you factor out the copy loop operation above and rename it into
> > 'copycontent' or 'copybytes' or whatever.
>
> Of course it should be factored out: but the question remains, why shell
> utils? Do you really think copybytes belongs there?
Add shutil.copyfileob(src_file_ob, dst_file_ob). shutil.copyfile() can call
it after opening the files.
Does that function make absolute sense there? Tough question. It sure
happens to work well, considered the dependent function copyfile(). I
imagine there are a bazillion functions that could be re-factored. No sense
getting overly concerned.
Put the bugger in shutil for now. Step two: propose a new organization.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/