Skip to content

Commit 14430f7

Browse files
Merge pull request #457 from cclauss/patch-1
Fix undefined name 'filename' in ftp_send_receive.py
2 parents ab7b37e + 4a630da commit 14430f7

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

ftp_send_receive.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@
1818
Enter the location of the file where the file is received
1919
"""
2020

21-
def ReceiveFile():
22-
FileName = 'example.txt' """ Enter the location of the file """
23-
LocalFile = open(FileName, 'wb')
24-
ftp.retrbinary('RETR ' + filename, LocalFile.write, 1024)
25-
ftp.quit()
26-
LocalFile.close()
21+
def receive_file(filename='example.txt'):
22+
with open(filename, 'wb') as out_file:
23+
ftp.retrbinary('RETR ' + filename, out_file.write, 1024)
24+
ftp.quit()
2725

2826
"""
2927
The file which will be sent via the FTP server
3028
The file send will be send to the current working directory
3129
"""
3230

33-
def SendFile():
34-
FileName = 'example.txt' """ Enter the name of the file """
35-
ftp.storbinary('STOR ' + FileName, open(FileName, 'rb'))
36-
ftp.quit()
31+
def send_file(filename='example.txt'):
32+
with open(filename, 'rb') as in_file:
33+
ftp.storbinary('STOR ' + filename, in_file)
34+
ftp.quit()

0 commit comments

Comments
 (0)