How to pass a new variable to python script using 'for' loop -


i trying write python script traverse through list , pass new variable other python script. here code:

script: encviewer.py

 # import necessary modules  import os   # list of encs  root = os.listdir('/home/cassandra/desktop/file_formats/enc_root')  root.sort()  root = root[2:]   enc in root:       # pass new instance of variable 'enc' encreader.py      import encreader.py 

script: encreader.py

from __main__ import * print enc .... # remaining script 

currently, when executing first code, encviewer.py, execute once exit. how can pass new instance variables of 'enc' encreader.py executes throughout entire 'for' loop seen in first snippet of code?

thanks.

i don't know if asking possible, think miss understood idea of creating modules , importing code. "standard" way of achieving same result following:

encreader.py

def printer(var):     print(var)     # code.. 

encviewer.py

 import os  encreader import printer   # list of encs  root = os.listdir('/home/cassandra/desktop/file_formats/enc_root')  root.sort()  root = root[2:]  enc in root:     printer(enc) 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -