postelrich
postelrich

Reputation: 3496

How to get attributes of uninitialized instance?

Lets say I have a class like below.

class Foo(object):
    def __init__(self, a, b):
        self.a = a
        self.b = b

Is there function that will allow me get all the attributes? For example:

attributes(Foo)
# [a, b]

From what I have been able to find, it seems it is only possible with class attributes.

Upvotes: 2

Views: 271

Answers (1)

BrenBarn
BrenBarn

Reputation: 251398

No, because those attributes do not actually exist until an instance is created.

Upvotes: 2

Related Questions