Ask coding questions

← Back to all posts
Why I can't run my second file
AshkiKudzma (41)

I want to run my second python file but it always run whatever i have in but not in second file i made.

HaykAprikyan (8)

Ctrl+Shift+P > Open Shell > type in "python [second file]"

chrisbarai (7)

@HaykAprikyan how you guys manage your python file
by making a single repository for a single file or by some other way

awesomefireligh (0)

@HaykAprikyan hi i was just wondering, but this is go on forever?

AliBaba1 (17)

To do this
go to your file
and write the following code in it

from filename import *

Remember replace filename in code with your desired filename to be run
Note: do not use keywords as your filenames.

aayushich6 (3)

@AliBaba1 It is working but then at the bottom it is showing an error.

Also, how would i import another file inside a folder??

timmy_i_chen (1187)

Here's an example of using multiple files in python:

paulfears (97)

that is because multible files are designed to be object oriented
you can run the other file by turning it into a class or function and importing it with the import command

or you could add this to

import os

chrisbarai (7)

@paulfears means we should only keep one file( in one repository?