Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

multifile Python project

+11 votes
asked Jan 18 by Cristiano De Pasquale (220 points)
Hello,

Is there any chance to create a project in Python with different files and choose which one to run?
a.py -- b.py -- c.py ...

I can actually only run main.py

Cheers!
Cris

1 Answer

0 votes
answered Feb 4 by Eidnoxon (4,850 points)

Yes! You can put your code into a function. E.g. a.py:

def runFunc():
      print("Hello from a.py!")

and then import that function from a.py to main.py:
from a import runFunc

If it's inside another folder:
from Folder.a import runFunc

and now main.py:
from a import runFunc
runFunc()

The output's gonna be "Hello from a.py!"
Not really sure what you mean by your question but here is my answer based on my assumption!

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...