About 8,500,000 results
Open links in new tab
  1. python - Getting the class name of an instance - Stack Overflow

    Feb 4, 2009 · How do I find out the name of the class used to create an instance of an object in Python? I'm not sure if I should use the inspect module or parse the __class__ attribute.

  2. python - Getting attributes of a class - Stack Overflow

    Jan 30, 2012 · I want to get the attributes of a class, say: a = "12" b = "34" def myfunc(self): return self.a. using MyClass.__dict__ gives me a list of attributes and functions, and even functions …

  3. How to Get a List of Class Attributes in Python? - GeeksforGeeks

    Nov 11, 2022 · In Python, creating a list of objects involves storing instances of a class in a list, which allows for easy access, modification and iteration. For example, with a Geeks class …

  4. python - Get attribute name of class attribute - Stack Overflow

    Yes, you can make the Field class a descriptor, and then use __set_name__ method to bind the name. No special handling is needed in MyClass . object.__set_name__(self, owner, name) …

  5. Python Program to Get the Class Name of an Instance

    Mar 22, 2023 · Using type() and __name__ attribute to Get the Class Name of an Instance. Also, we can also print the type of c (class car) which gives the object of c and __name__ provides …

  6. Python Class: Getting Attributes by Name and the

    Jan 21, 2025 · Python provides the getattr() function to retrieve an attribute of an object by its name (as a string). The syntax is getattr(object, name[, default]). The object is the instance of …

  7. Python Get Class Name: Unveiling the Basics, Usage, and Best …

    Jan 29, 2025 · Whether you're debugging, logging, or implementing metaprogramming techniques, knowing the class name of an instance provides valuable insights into the object's …

  8. Python: Getting the Name of a Class - CodeRivers

    Mar 20, 2025 · In Python, getting the name of a class can be achieved through various methods, from the simple __name__ attribute to more advanced techniques like metaclasses and …

  9. Understanding Python Class Attributes By Practical Examples

    Use class_name.class_attribute or object_name.class_attribute to access the value of the class_attribute. Use class attributes for storing class contants, track data across all instances, …

  10. How to Get Class Name in Python? - FavTutor

    Dec 28, 2021 · The first and easiest method to get a class name in python is by using __class__ property which basically refers to the class of the object we wish to retrieve. Here we combine …

  11. Some results have been removed
Refresh