only main.py files is running. How to run the other files .py files
Hi,
I am newbie to REPL. I am just checking how to use python online. I created a file but when ever i run my pythion script, it always runs the main.py only. How to made the compiler to run my file?
Bookie0
Hi!
you have to do this: from file_name import *
(the star sign *
means everything) and replace file_name
with what you want. in your case its hello
then when you press run it should print what you wrote in the other files.
Happy coding and hope this helps! =)
mail2kvanitha
i want python to run my other file hello.py
PythAthu
Hi
@mail2kvanitha, I think you should run this code if the file is in a folder: from foldername import filename with or if you have the file outside any folder then you have to run this code: import filename. And if you put an extension eg: filename.py then it will be and invalid syntax.Thanks
Regards,
@PythAthu
PattanAhmed
@mail2kvanitha Hi,
I think You can import that file only if it is under a folder, As a project, Not just as another individual file...
So,
You can create a folder and name
I think You can import that file only if it is under a folder, As a project, Not just as another individual file...
So,
You can create a folder and name
xxx
and put that two files under that and can type import command
and try:- Your code should look like this.:-
import xxx # And can use any code from that file.
Make sure that two files are under one folder anywhere whether it may be Repl.it or other.
Hope this helps.
Please mark my answer if this helps.
Muffinlavania
just import hello in main.py
import hello
then if you have this in hello.py,
print("I like turtles")
it will print that and whatever
rm main.py