Python Forum
Calling a Returned Value to Another Function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling a Returned Value to Another Function
#3
What should be the "some_env_var_name" in this case ?

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$
Reply


Messages In This Thread
RE: Calling a Returned Value to Another Function - by valerydolce - Mar-10-2017, 02:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Sorting Data Returned From Database Timbo03 9 2,382 Feb-19-2023, 02:12 PM
Last Post: Larz60+
  Calling a function from another function johneven 2 2,997 Jul-09-2019, 12:42 AM
Last Post: micseydel
  Calling function-- how to call simply return value, not whole process juliabrushett 2 3,318 Jul-01-2018, 01:17 AM
Last Post: juliabrushett
  Calling a function to return a list of percentages Liquid_Ocelot 7 6,530 Mar-25-2017, 01:20 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020