Ned Batchelder <n...@nedbatchelder.com> writes: > Generally, my answer would be, "You probably don't need the type as > much as you think you do." > […] > Also, don't overlook isinstance().
Agreed. > But when you do need it, type(x) is better than x.__class__, simply > because we should always favor builtin functions over direct access of > dunder-names where possible. Thanks. Should we expect (ignoring pathological cases) the assertion ‘type(obj) is obj.__class__’ to hold true? If not, under what circumstances would it be sensible for those to differ? -- \ “For fast acting relief, try slowing down.” —Jane Wagner, via | `\ Lily Tomlin | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list