Forum Archive

how to change the file extension

jose3f23

I have saved a file named file.txt but it appears actually to be file.txt.py.

How can I avoid the .py extension ?

Thanks.

jugisto135

Well, Pythonista's purpose is to be a working editor and environment for Python, so afaik it is not intended to be a fully functional file manager and editor.

But as it is more than just a file manager or editor, Pythonista does allow for a file manager being written in Python and run in the console. Here's a nice one:

http://omz-software.com/pythonista/forums/discussion/74/advanced-shell-shellista

As for creating and writing a file, use Python's built-in open(), like this:

with open('test.txt', 'wb') as file:
file.write('This is a test.')
file.close()

jose3f23

Thank you very much . Good link.

I have managed to change the file name using:

os.rename('file.txt.py','file.txt')