次のように、クラス内で外部ライブラリのメソッドを複数回呼び出します。
class MyClass:
const_a = "a"
const_b = True
const_c = 1
def push(self, pushee):
with ExternalLibrary.open(self.const_a, self.const_b, self.const_c) as el:
el.push(pushee)
def pop(self):
with ExternalLibrary.open(self.const_a, self.const_b, self.const_c) as el:
return el.pop()
ステートメントを含む行は、with
毎回定数を引数として渡す必要があるため、私を悩ませています。タプルのような事前定義されたデータ構造に引数を格納し、それを外部ライブラリに渡したいと思います。