Ask coding questions

← Back to all posts
How to run another python file (not the ?
FrancoisFaideau (1)

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

AlexanderTarn (280)
  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)
MrEconomical (2282)

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

omck (0)

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

AlexanderBirabe (101)

Say you have a file called ''. In your 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

abc3354 (225)

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

ColinKirsch (0)

how do i import a file to my damn repl? i need to know! may help with a project im working on and will help with [email protected]