Describe the feature you want to add
Refactor filename and extension handling in tsave() to make file path processing cleaner, safer, and easier to maintain.
Describe your proposed solution
Import Path from Python's pathlib module and replace the manual string-based filename parsing:
- Splitting filenames with .
- Reversing strings to find extensions
-Manually building filenames and extensions
with Path methods:
Path(filename).suffix to detect extensions
Path(filename).with_suffix("") to get the filename without extension
Use Path.exists() instead of checking against os.listdir() when determining whether a filename already exists.
This simplifies the code and avoids edge cases with filenames containing multiple dots.
Describe alternatives you've considered, if relevant
No response
Additional context
No response
Describe the feature you want to add
Refactor filename and extension handling in
tsave()to make file path processing cleaner, safer, and easier to maintain.Describe your proposed solution
Import
Pathfrom Python'spathlibmodule and replace the manual string-based filename parsing:-Manually building filenames and extensions
with
Pathmethods:Path(filename).suffixto detect extensionsPath(filename).with_suffix("")to get the filename without extensionUse
Path.exists()instead of checking againstos.listdir()when determining whether a filename already exists.This simplifies the code and avoids edge cases with filenames containing multiple dots.
Describe alternatives you've considered, if relevant
No response
Additional context
No response