Mar-10-2017, 02:29 PM
What should be the "some_env_var_name" in this case ?
When i test the code below,
When i test the code below,
#! /usr/bin/python3 import os import sys def get_environment_variable_value(variable_name): var_name = os.environ[variable_name] if not var_name: return "" else: return var_name def get_dirs_from_path(): path_var = get_environment_variable_value(variable_name) directories = path_var.split(':') for entry in directories: print (entry) get_environment_variable_value('PATH') get_dirs_from_path()it prints the following output:
Output:psimo@itserver6:~/it117/hw/hw6$ ./hw66.py
Traceback (most recent call last):
File "./hw66.py", line 22, in <module>
get_dirs_from_path()
File "./hw66.py", line 15, in get_dirs_from_path
path_var = get_environment_variable_value(variable_name)
NameError: name 'variable_name' is not defined
psimo@itserver6:~/it117/hw/hw6$