0

I am using Python 3.8.3 on Windows, I'm very new at OOP.

I am working on some trello stuff for work and I wanted to create a trello object so I can call them across the various functions. I had this working previously under FP but since converting it over it isn't working as expected for me.

What I'm trying to do is get a dict back from the method to assign to a variable, however when I do a test and print the result, this is what I get:

<function TrelloInfo.members at 0x00000...>

Please see below for code:

class TrelloInfo():
    
    def __init__(self):
    
        # account key and token
        self.query = {
        'key': 'key',
        'token': 'token'
        }

    def cards(self):
        # get card info
        urlcards = "cardurl"

        responsecards = requests.request(
        "GET",
        urlcards,
        params=self.query
        )

        cleanedupcards = json.loads(responsecards.text)

        return cleanedupcards

    def members(self):

        # get member info
        urlmembers = "memberurl"

        responsemembers = requests.request(
        "GET",
        urlmembers,
        params=self.query
        )

        cleanedupmembers = json.loads(responsemembers.text)

        return cleanedupmembers

    def lists(self):
        # get lists in the board
        urllists = "listsurl"

        responselists = requests.request(
        "GET",
        urllists,
        params=self.query
        )

        cleaneduplists = json.loads(responselists.text)

        return cleaneduplists

    def labels(self):
        # get label info
        urllabels = "labelsurl"

        responselabels = requests.request(
        "GET",
        urllabels,
        params=self.query
        )

        cleaneduplabels = json.loads(responselabels.text)

        return cleaneduplabels
    
test = TrelloInfo

cards = test.cards
members = test.members

print(members)

I feel like I'm missing something really small but I haven't been able to find an answer.

2 Answers 2

7

You'll want to create an instance of your class, rather than assigning the class itself to a variable, which basically just creates an alias for that class:

test = TrelloInfo()

Then, you'll want to invoke the methods of that instance:

cards = test.cards()
members = test.members()
0
3

Your problem here is that your actually setting members to be a pointer to the class method members without executing it.

You have to add () to execute it:

test = TrelloInfo()

cards = test.cards()
members = test.members()
2
  • 1
    wait until you send stuff like that for review when your getting paid for it :P Jul 3, 2020 at 17:26
  • #thatsthedream... slowly working on my skills to be able to do this full time. Jul 3, 2020 at 17:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.