Ask coding questions

← Back to all posts
How to run another python file (not the main.py) ?
FrancoisFaideau (0)

It surely simple to do this but I don't know how.
Can anyone help me?
Thanks

Commentshotnewtop
MrEconomical (2237)

make a .replit file and then you can put any run command in it
for example in your .replit file:
run = "python myfile.py"

omck (0)

@MrEconomical will this work if i make them files in one program?

AlexanderTarn (274)
  1. create a new file with (name).py
  2. write your code in it
  3. go to main
  4. import (name)
  5. use functions in file : (name).(function)(parameters)
AlexanderBirabe (100)

Say you have a file called 'file2.py'. In your main.py file, type the line:
import file2

This runs the entire file as if it were a part of your main one, so any variables or functions in file2 will still be able to be referenced within main.py.

abc3354 (223)

Hello !
If you want us to help you, you will have to ask a question or to post some code ;)
This is a guide on how to ask questions