[Tutor] Global Variables
Joseph Fennell
josephfennellster at gmail.com
Fri Nov 20 21:51:25 CET 2009
Quick introduction, I'm Joseph Fennell, and I've been playing with python
for the past 6 years (primarily in the interpreter) and have finally gotten
started on a full project and I've run into a small problem. I have defined
some modules, and when I import them into the page I want to use them on
after I run the program it tells me the variable I'm trying to pass through
them is not defined.
I assume that it's because the variable is considered local and the imported
functions are not technically local to that document.
The code is to pass the contents of a database through to filter by name and
quantity and as follows
=================================================
cHandler.execute("SELECT * FROM table")
#sets results from above to nl
nl = cHandler.fetchall()
dn = raw_input("User input: ")
nl2 = []
dname()
########
def dname():
global nl
for ndc in nl:
if ndc[1] == dn:
nl2.append(ndc,)
else:
continue
#########
tuple(nl2) = nl2
qtysrch()
#########
def qtysrch():
global nl2
for ndc in nl2:
if ndc[7] == 0:
continue
else:
print ndc
Any help I can get with this problem would be greatly appreciated.
Thanks
Joseph L. Fennell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091120/bf6e78f8/attachment.htm>
More information about the Tutor
mailing list