How to run a file other than main.py

I just made a new .py file, but for some reason when I print output it ONLY works for my main.py…as in the console only works properly if the code is in main.py and it will completely ignore any code in the new .py file I created…any ideas on what to do?

1 Like

When you slick RUN it only run main.py, but this can be changed by modifying the .replit file

see here

https://docs.replit.com/programming-ide/configuring-repl

4 Likes

That happens because the run and entrypoint in .replit is set to main.py only, and not new.py. To solve this, click on the three dots on the filemenu, click show hidden files, and go to .replit. Change the entrypoint variable to new.py.

3 Likes

Oof… You beat me to it. Also, run is useless.

2 Likes

This is not a contest, id it? :slight_smile:

2 Likes

Hey @AngelicaWest, welcome to the community!

Just click the three dots 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.

You can also change the second line from run="run_command_for_lang main.py" to run="run_command_for_lang fileIWantToRun.py", though it won’t have an effect for interpreted languages as shown in the comment on line 1.

Images

Dots

Show hidden files

edited

5 Likes

It starts to feel like a contest now

2 Likes

It is a contest. Who can get on top of the cheers lb.

3 Likes

It IS a contest. Who was the most helpful? Who answered the quickest?
Who’s the winner? The person who got Solution.

Also, is*

4 Likes

Lucky for you (whatever pronoun i need to use), i do not care about the cheers.

4 Likes

But, if you consider it, what can you get by having a post marked as solution? It won’t put more knowledge in your head. It won’t put money in your pocket. The reason I answer questions is for learning.

2 Likes

Umm… Badges…

https://ask.replit.com/badges/102/solved
https://ask.replit.com/badges/103/guidance-counsellor
https://ask.replit.com/badges/114/know-it-all
https://ask.replit.com/badges/115/solution-institution

Though, I also answer questions to learn more.

2 Likes

I answer just to help. And sometimes i learn form it too and that is great

5 Likes

Badges won’t give you knowledge, or put money in your pocket, same as solutions. Also from* @fpessolano .

3 Likes

So we now know that changing account name does not updates posts where you were mentioned :slight_smile:

4 Likes

Did you change the Replit or Ask username?

1 Like

Replit and as result ask also.

1 Like

In the .replit file I use this line

run = "python3 $(ls -t *.py | head -n1)"

Doing this way when you press RUN button replit will execute latest python saved file.

2 Likes

How about running multiple codes?

1 Like

You can just use a for loop I guess. Remember that the run variable executes the value as a bash command.

3 Likes