Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: FileAlreadyExistsError #1

Open
aviadr1 opened this issue Jan 26, 2023 · 1 comment
Open

bug: FileAlreadyExistsError #1

aviadr1 opened this issue Jan 26, 2023 · 1 comment

Comments

@aviadr1
Copy link

aviadr1 commented Jan 26, 2023

if the last file (i.e. fileName+"."+str(i+1)) already exists, os.rename will not overwrite it (at least not on windows machines)

os.rename(self.fileName+"."+str(i),self.fileName+"."+str(i+1))

therefore it is advisable to delete the last file before rotation

@aviadr1
Copy link
Author

aviadr1 commented Jan 26, 2023

from the python docs
os.rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)
...

On Windows, if dst exists a FileExistsError is always raised.
...

If you want cross-platform overwriting of the destination, use replace().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant