Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a61bdeb

Browse files
committed
add delete() method to ftp object
1 parent d9e9f9c commit a61bdeb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Lib/ftplib.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,16 @@ def rename(self, fromname, toname):
358358
raise error_reply, resp
359359
self.voidcmd('RNTO ' + toname)
360360

361+
# Delete a file
362+
def delete(self, filename):
363+
resp = self.sendcmd('DELE ' + filename)
364+
if resp[:3] == '250':
365+
return
366+
elif resp[:1] == '5':
367+
raise error_perm, resp
368+
else:
369+
raise error_reply, resp
370+
361371
# Change to a directory
362372
def cwd(self, dirname):
363373
if dirname == '..':

0 commit comments

Comments
 (0)