Skip to content

mate-academy/py-copy-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy file

Write a function copy_file that will copy a file in current directory like Linux cp command: cp file.txt file-copy.txt. Function take only one argument command, that is string with command cp, file name to copy and new file name, separated by spaces.

  • It must do nothing in case the user is trying to copy file to file with the same name.
  • Function must copy the whole content to new file. Example:
copy_file("cp file.txt file.txt")  # Does nothing

copy_file("cp file.txt new_file.txt")
open("file.txt").read() == open("new_file.txt").read()  # True

Note: You can use two contexts managers simultaneously by separating them by a comma:

with open(..., "r") as file_in, open(..., "w") as file_out:
    ...

Note: Check your code using this checklist before pushing your solution.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages