Small bug in docs

The very first sample code on the site seems to contain an error: ​https://ftputil.sschwarzer.net/trac/wiki/Documentation#introduction

    with ftp_host.open("index.html", "rb") as source:
        with ftp_host.open("newdir/index.html", "wb") as target:
            ftp_host.copyfileobj(source, target)  # similar to shutil.copyfileobj

Unless I'm mistaken and my working code is doing something it should not, that should be "with open( ... as source", as a local file, and with "ftp_host.open( ... as target" for the remove file. That is, you're opening the local file as a regular Python file object, not as an ftputil remote object.

ftputiluser (unverified)
Assigned to
3 years ago
3 years ago
bug library

schwa (unverified) 3 years ago · edit

It should be possible to copy a remote file to another remote location, as in the example code. Remote files support reading and writing. So I think the code is intentional as it is.

When you say

Unless I'm mistaken and my working code is doing something it should not,

what did you try and in which way did it fail?

ftputiluser (unverified) 3 years ago · edit

My apologies -- somehow I missed the remote file in the comments. Please allow me to hang my head in shame and slink out, while offering thanks for your time and intelligence.

schwa (unverified) 3 years ago · edit

Now, now, it's fine. We all make mistakes. :-)

I do appreciate that you entered a ticket about a documentation bug! Not many people do this. Of course it's possible that a bug isn't really a bug, but naturally you don't know this in advance. So relax and keep entering such tickets. :-)

schwa (unverified) 3 years ago · edit

Closing this as "invalid" because it's not actually a mistake.

Register here or Log in to comment, or comment via email.