0

I have two different scripts. I want to get one variable from the script to use another script. I try that method but its give me this answer shown below.

scrip1.py

a=7
print(a)
c =10
print(c)
b=5

script2.py

from script1 import b
print(b)

result is :

7
10
5

How can i get just value of b and the output will be ? :

5
Gusto_
  • 1
  • 2
  • Why print in the first script if you don't want to print? The answer is to use an import guard, but you may want to reconsider printing in the first file anyways. – Carcigenicate Jan 09 '20 at 14:00
  • Kind of a backwards duplicate, but it answers your question. Wrap the prints in the first file in `if __name__ == "__main__":`. That's explained in the linked post. – Carcigenicate Jan 09 '20 at 14:01

1 Answers1

0

try with this

scrip1.py

def a() : print(7)
def b() : print(5)
def c() : print(10)

scrip2.py

from a import b
b()