Oct-04-2019, 12:33 AM
Good evening......
Can someone please tell me the correct way to create a variable within a method and then be able to re-use that variable internal to the class within another method? As an example I tried this below with __usb and __SG....in particular __SG gets defined in open method and I want to re-use it in close method...Thank you for all responses
Can someone please tell me the correct way to create a variable within a method and then be able to re-use that variable internal to the class within another method? As an example I tried this below with __usb and __SG....in particular __SG gets defined in open method and I want to re-use it in close method...Thank you for all responses
def open(self):
k = visa.ResourceManager()
try:
__usb = k.list_resources()[1]
except IndexError:
print ('Make sure equipment is turned on')
try:
__SG = k.open_resource(__usb)
except:
print ('USB Resource could not be opened')
else:
print ('Success opening USB resource')
def close(self):
__SG.close()
print ('Success closing resource')
