yoonjesung yoonjesung -4 years ago 150
Python Question

Determining object class in ndb PolyModel Google App Engine

It looks like the

class used to have a
method but as far as I can tell it has been deprecated.

I have a data structure using polymodel that is in the form of a parent User class with two child classes - Employee and Manager, and I want to do some basic checks throughout to determine if the User object is of the class Employee or class Manager.

At the moment, I am just calling the object's
attribute directly, but I am wondering why the
method was deprecated. Is there a better way to determine class inheritance?

Answer Source

Per comments above it looks like what you need is isinstance(user, Employee) / isinstance(user, Manager).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download