0

At FactsheetExporter I have data instance variable. I need to pass data as instance variable to Parameter class but have no ideas how. Do you know how to make it?

class FactsheetExporter:
    def __init__(self):
        self.data = {somedata...}

class Parameter:
    def __init__(self):
        self.data = data

    def compute(self):
        do_stuff(self.data)
        # do data stuff...

class PortfolioFactsheetExporter(FactsheetExporter):
    class Meta(FactsheetExporter.Meta):
        name = "export_portfolio_factsheets"
        entities = Parameter()
1
  • You use the word "metaclass" in your title, but there are no metaclasses in your code. There is a class named Meta. What is that supposed to do? The desired relationships between these classes aren't exactly clear. Could you describe exactly what those relationships should be? Commented Nov 19, 2018 at 20:33

1 Answer 1

1

data here is an instance variable of class FactsheetExporter. So, you have to send the instance of FactsheetExporter to Parameter in order to be able to access data.

class FactsheetExporter:
    def __init__(self):
        self.data = {somedata...}

class Parameter(FactsheetExporter):
    def compute(self,FactsheetExporter_var):
         data = FactsheetExporter_var.data
         # do data stuff...


object1 = FactsheetExporter()
#Object1 should be passed to Parameter in order for it to be able to access data variable
object2 = Parameter(object1)
object2.compute(value_for_data)
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. But I can't kick out PortfolioFactsheetExporter class

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.