omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    how to change the file extension

    Pythonista
    2
    3
    2331
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jose3f23
      jose3f23 last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • jugisto135
        jugisto135 last edited by

        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:

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

        1 Reply Last reply Reply Quote 0
        • jose3f23
          jose3f23 last edited by

          Thank you very much . Good link.

          I have managed to change the file name using:

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors