How to save and run a python file

Question:
i want to run my new python file, but each time i run code, previous python file gets run…

Replit Profile: https://replit.com/@mehtansh1st

1 Like

Hey @mehtansh1st!

Just click the next to “Files” then click Show hidden files. Next click on the .replit file and finally you can change the entrypoint to whatever file you want to run.

Images

Dots

Show hidden files

edited

You should also see the docs on how to configure a Repl: https://docs.replit.com/programming-ide/configuring-repl

And if you want to run the last edited file, take a look at this post:

3 Likes

When you want to start a new file, you can rename the current one from main.py to something else


image

Then, create the new file and name it main.py.
image

Now when you click run you’ll see the output of the new code, and you don’t have to mess with the .replit file.

You should be aware though that the history of the file will not be copied over when you rename it, the history remains in main.py and can be recovered when you recreate main.py.


Also, you could, when you’re ready to make a new file, duplicate the current file, (saving a copy of it,) and then erase the contents of main.py and write your new code.

Like in the previous version, the history is not copied over when you duplicate the file, and instead remains in main.py.


You can also always just delete your current code in main.py and then write your new code. Then, whenever you want to go back to one of the previous versions just use the file history, though you should make note of the significant history points to prevent losing your working code if you’re working through lots of errors and making tweaks.

Write the new code.
image

Then use history to go back to the previous code.

1 Like