how to initialize environmental variables and how to understand simulation module in python? -


first question: have python program , after run it, following error:

traceback (most recent call last):   file "myfile.py", line 242, in <module>      out_dir = os.path.join( dir, "myfile-{0}".format(os.environ['job_id']) )    file "/apps/x86_64/python 2.7.6/lib/python2.7/userdict.py", line 23, in _getitem_    raise keyerror(key)   keyerror: 'job_id' 

is because did not initialize environmental variables in command line prompt? userdict involved dictionary, right?

second question: how grasp main initialization of simulation in python? example, suppose have following code.

sim= simulation.simulation ( { key : value }, a, time_step_size, expected_rates_logisticrk4 ) 

how understand then? relatively new python. many time , attention.

you should split question two, however, first question, exception raised because there no job_id environment variable set in python program's environment. firstly can set on command line when invoking python:

$ job_id=100 python myfile.py 

or can set variable in shell's environment:

$ export job_id=100 $ python myfile.py 

either of these fix problem, however, should code more defensively catching exception, or using os.environ.get('job_id') not throw exception if environment variable not set.

for second question should reask new question , in explain more accurately module being used.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -