Ask coding questions

← Back to all posts
How would I....
ElijahNarvaez (11)

yes, its your boy back at it again to ask more stupid questions. anyway, how would i go about using the variables in coolfile.py. also am i importing file right?

Answered by Coder100 (18904) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18904)
  1. no you are not importing the file correctly. You are running coolfile.py, but remember, because you are running it, main.py can't use the variables.

  2. You can import variables, or import them all. To import all the variables,

from coolfile import *

to import them all, but you have to reference them like: coolfile.x

import coolfile

and lastly, to import only specific ones, like the var x

from coolfile import x

i recommend using the second option.

CosmicBear (45)

To import it use import coolfile. This will run the file "coolfile.py" which creates the variables inside "main.py".

EDIT: That is actually incorrect use from coolfile import variable instead.

CosmicBear (45)

also did you have the replit db on this repl because it's installing all the dependincies needed for the db.

CosmicBear (45)

and also the ones needed for flask