I am just learning python (as of today), and I am having an issue with 'import'
I am writing two scripts inputGen.py and frequency.py:
# inputGen.py
import sys
def readInputWords():
while 1:
line = sys.stdin.readline()
if line=='': return
words = line[:-1].split()
for word in words:
yield word
for word in readInputWords():
print word
# frequency.py
import inputGen
def countInputWords():
for word in inputGen.readInputWords():
# the rest of countInputWords()
countInputWords()
The problem is that the moment I import inputGen, the entire script is run. Is there some way that I can use readInputWords() in frequency.py without running inputGen.py?