I have to create a function, printObjects(attribute, option), which must print the objects based on a certain attribute. The attribute can take ints or strings as input. The option attribute is optional. How do I implement this for my class?
I have to create a function, printObjects(attribute, option), which must print the objects based
Share
I assume you want something like this, or perhaps it will be helpful at least:
def printObject(obj, attributes=()): for a in attributes: print getattr(obj, a)