Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:在内存中存储令牌_Python_Variables_Memory_Store - Fatal编程技术网

Python:在内存中存储令牌

Python:在内存中存储令牌,python,variables,memory,store,Python,Variables,Memory,Store,我有一个类,在这个类中我有一个执行身份验证并返回令牌的函数 我想将该令牌存储在内存中,供同一类中的其他函数使用 我该怎么做 假设这样的结构: class myClass(object): def doAuth(self): callAuthProcedure() 如果callAuthProcedure返回令牌,只需调整它即可: class myClass(object): def doAuth(self): self.token = callAuthProcedure(

我有一个类,在这个类中我有一个执行身份验证并返回令牌的函数

我想将该令牌存储在内存中,供同一类中的其他函数使用


我该怎么做

假设这样的结构:

class myClass(object):
  def doAuth(self):
    callAuthProcedure()
如果callAuthProcedure返回令牌,只需调整它即可:

class myClass(object):
  def doAuth(self):
    self.token = callAuthProcedure()

稍后,类实例上的其他方法可以根据需要使用self.token。

假定结构如下:

class myClass(object):
  def doAuth(self):
    callAuthProcedure()
如果callAuthProcedure返回令牌,只需调整它即可:

class myClass(object):
  def doAuth(self):
    self.token = callAuthProcedure()

稍后,该类实例上的其他方法可以根据需要使用self.token。

显示代码以获得更多有用的答案。正是这些问题让我对StackOverflow社区产生了温暖而模糊的感觉:人们愿意学习,人们礼貌地教学。展示代码以获得更多有用的答案。正是这些问题让我对StackOverflow社区产生了温暖而模糊的感觉:人们愿意学习,人们礼貌地教学。