Python changes some filename characters on macOS

Python’s own idle will turn “:” into “-” when you enter a filename when saving a file, and the Chinese braces “(” will turn into “-” when you write code. “backspace”.

My version is python 3.8.6 macos.

MacOS used “:” as a path separator, so it couldn’t be used in a filename.

Modern MacOS is Unix underneath, and that uses “/” as a path separator, but as MacOS tries to hide that detail, it shouldn’t be too surprising if you still can’t use “:” in a filename.

1 Like

It is python, not IDLE, that alters filenames. IDLE calls the tkinter savefile dialog and that, I presume, calls the stdlib open() function. Mathew, thanks for the historical detail.

I suspect you are seeing the macOS Finder change the filename for presentation. From a terminal you will see the “:” but not from the GUI I recall.

This is nothing to do with python.
Try creating files in Finder with a : and from the terminal.
Then view in each to see what macOS does.