I have a class function where if optional parameter(yaml file) is passed then read the values and pass it as optional parameters to the def books() function. But executing the below code, I get error as 'name 'self' is not defined. How can I read the yaml items into the books function as an optional parameter?
class Price:
def __init__(self, *args):
if args:
with open(args, 'r') as f:
stream = yaml.load(f, Loader=yaml.FullLoader)
bookname= stream['book']['name']
self.param = bookname
else:
self.param = None
return self.param
def books(self, file, name=self.param):
print(file,name)