[Tutor] Global var not defined?
leam hall
leamhall at gmail.com
Tue Aug 27 19:58:14 CEST 2013
Could use some help with this. Python 2.4.3 on RHEL 5.x.
In the functions file that gets imported:
def append_customer(line_list):
global customers
cust = line_list[0] // list with Customer info in [0]
cust = clean_word(cust) // Trims white space
if len(cust) and cust not in customers:
host_list[cust] = {}
customers.append(cust)
In the calling file:
import functions
import sys
customers = []
.
.
.
for line in input_file:
line = line.strip()
if not len(line):
continue
line_list = line.split(',')
functions.append_customer(line_list)
Error message:
Traceback (most recent call last):
File "./host_tools.py", line 55, in ?
functions.append_customer(line_list)
File "/home/lhall/lang/functions.py", line 27, in append_customer
if len(cust) and cust not in customers:
NameError: global name 'customers' is not defined
--
Mind on a Mission <http://leamhall.blogspot.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130827/22bb4609/attachment.html>
More information about the Tutor
mailing list