Can i print an object?

Hey, can I print all attributes of an object at once? I think i’ve done this but im not sure it couldve been something else. example:

class Boy(object):
  def __init__(self, name, age): = name
    self.age = age

James = Boy('James', 18)

print(Boy.James)                     # Or something similiar 

Sure, you can print almost everything.

Print an attribute of an instance of a class: print(

Print a representation of the whole instance: print(james)

Just play around with these in the REPL. See what print(Boy) does. :wink:

1 Like

Yep, and also add a repr function too:

3. Data model — Python 3.9.7 documentation.repr