Post

PythonPython

k
kavya A

Posted on 27th February 2024|14 views

0
votes

Python Get Class Name

How to get a class name of an instance?

Answers
P
persis crystal

Posted on 27th February 2024

Just go through this simple example which might help you

class human(object): 

def init(me,my_name): 

me.my_name=my_name 

def info(me) 

print "My name is {0}, I am a{1}".format(me.my_name,me.__class__.__my_name__) bob = human(name='Angel')

bob.info()

Output:

My name is Angel, I am a human

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos