Trying to create backup for my files:
name = input("Enter the name:" (\"/\" to quit)\n>>>")
name += ".vcblr"
write_file(name, ([], [], [], []))
def write_file(file, content) -> None:
file = open(f"PythonVocabulary/{file}", "wb")
pickle.dump(content, file)
file = open(f"PythonVocabulary/backup/{file}", "wb")
pickle.dump(content, file)
Error I'm getting:
OSError: [Errno 22] Invalid argument: "PythonVocabulary/backup/<_io.BufferedWriter name='PythonVocabulary/german.vcblr'>"
Is the problem in duplicating files?
You're overwritting
filewith result ofopen. So use different variable names, and usewithso the file descriptor is closed automatically