Accessible variables at the root of a python script -


i've declared number of variables @ start of script, i'm using them in number of different methods ("functions" in python?). when try access them, can't seem value = or set them value matter. example:

basefile = open('c:/users/<redacted>/documents/python dev/atm/data.icsf', 'a+') secfile = open('c:/users/<redacted>/documents/python dev/atm/security.icsf', 'a+')  def usrinput(raw_input):     if raw_input == "99999":         self.close(true)     else:         identity = raw_input  def splitvalues(source, string):     if source == "ident":         usrtitle = string.split('>')[1]         usrfn = string.split('>')[2]         usrln = string.split('>')[3]         x = string.split('>')[4]         usrbal = decimal(x)         usrbaldisplay = str(locale.currency(usrbal))     elif source == "sec":         usrpin = string.split('>')[1]         pinattempts = string.split('>')[2]  def openaccount(identity):     #read file first. it's f***ing heavy it'll here.     plstring = basefile.read()     xlist = plstring.split('|')     parm = str(identity)     in xlist:         substr = i[0:4]         if parm == substr:             print "success"             usrstring = str(i)         else:             lnumfunds = lnumfunds + 1           splitvalues("ident", usrstring) 

when place basefile , secfile in openaccount method, can access respective files normal. however, when place them @ root of script, in example above, can no longer access file - although can still "see" variable.

is there reason this? reference, using python 2.7.

methods ("functions" in python?)

"function" when "stand free"; "methods" when members of class. so, functions in case.

what describe work in python. hence, diagnosis read file elsewhere before call openaccount, read pointer not @ beginning of file.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -