Top "Python-datamodel" questions

For questions about various details related to Python data model: built-in types, classes, metaclasses, magic __dunder__ methods, operators, object initialization, attribute lookup, etc.

Getting the class name of an instance?

How do I find out a name of class that created an instance of an object in Python if the …

python introspection instanceof python-datamodel
Is there a built-in function to print all the current properties and values of an object?

So what I'm looking for here is something like PHP's print_r function. This is so I can debug my …

python debugging introspection pretty-print python-datamodel
What are metaclasses in Python?

In Python, what are metaclasses and what do we use them for?

python oop metaclass python-datamodel
How to get method parameter names?

Given the Python function: def a_method(arg1, arg2): pass How can I extract the number and names of the …

python decorator introspection python-datamodel
Get fully qualified class name of an object in Python

For logging purposes I want to retrieve the fully qualified class name of a Python object. (With fully qualified I …

python python-datamodel
Implementing slicing in __getitem__

I am trying to implement slice functionality for a class I am making that creates a vector representation. I have …

python slice python-datamodel
Get class that defined method

How can I get the class that defined a method in Python? I'd want the following example to print "__main__.…

python python-2.6 python-datamodel
How is the 'is' keyword implemented in Python?

... the is keyword that can be used for equality in strings. >>> s = 'str' >>> s …

python python-datamodel built-in
Should I implement __ne__ as the negation of __eq__ in Python?

I have a class where I want to override the __eq__ method. It seems to make sense that I should …

python comparison operators python-datamodel
How Do I Perform Introspection on an Object in Python 2.x?

I'm using Python 2.x and I have an object I'm summoning from the aether; the documentation on it is not …

python introspection python-datamodel