Update ftplib.rst documentation#11023
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
| drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools | ||
| '226 Directory send OK.' | ||
| >>> ftp.retrbinary('RETR README', open('README', 'wb').write) | ||
| >>> ftp.retrbinary('RETR README', open('README', 'wb').write) # Download the file README |
There was a problem hiding this comment.
Hi @pinguin999, thanks for improving the documentation!
It seems to me that the file you open here is not closed before doing the upload next line. Shouldn't you close it before opening it again and reading from it?
Maybe we should use context managers here, after all, it probably isn't great to encourage beginners to keep their files open.
|
Hi @pinguin999, thanks for trying to enhance the documentation. IIRC this has already been proposed (can't find where though), and was refused because it make the example unrealistic (a user have a high chance not having the rights to write on ftp.debian.org). I think the example is enough demoing the lib, it's short and readable, I don't think we need to add every ftplib function in it. And the |


Update docs for FTP lib
The docs only showed how to download a file via FTP but not how to upload a file.
Now the docs have an example for download and upload files via ftp.