Here is my Function.........
from instrument import Instrument
import pandas as pd
def getpairsData():
global pairlist <<============= Defined Global variable
pairlist = Instrument.get_pairs_from_list() <<=============Call
return pairlist <<============= Available Global variable
"""It is being called by this loop....... #This loop will iterate over pairlist, and will pass one pair to get data, and save that data as file."""
for pair in pairlist: <<======= My Global variable above????
getData()
for i in range(0,11):
df1= pd.read_csv("./data/"+ str(files[i])+".csv")
print (df1.head())
import pandas as pd
import Utils
class Instrument():
def __init__(self,ob):
self.name=ob['name']
self.type=ob['type']
self.displayName = ob['displayName']
self.pipLocation = pow(10,ob['pipLocation']) # ex. - --> 0.0001
self.marginRate = ob['marginRate']
@classmethod
def get_pairs_from_list(cls): <<============= Receive Call 1
i_list = cls.get_instruments_list()
i_keys = [x.name for x in i_list]
df = pd.DataFrame(i_keys)
df = df.rename(columns={0: "Names"})
df['Names'] = df['Names'].str.replace("_", '')
print("You are here")
pairlist = df["Names"].tolist() # if it is being changed to a list with no keys
return pairlist <<============= Return Call 1
"""I am thinking the pairlist would return to the original function that is set as a Global variable and off to the races we go, but I am stuck on the print("You are here") not responding at all.
NameError: name 'pairlist' is not defined"""
for pair in pairlist:? Is thatforloop in a function? Have you calledgetpairsData()before you get to this loop? It looks like you haven't called getpairsdata to set the variable.getpairsData()?