I'm looking for a way to catch all the std type functions in Python (int, str, xrange, etc).
Basically anything which has a repr that looks like <type X> instead of <class X>. Here's a full list of all std types in Python 2:
https://docs.python.org/2/library/stdtypes.html
If I use isinstance(X, type) or type(X) == type, it also catches all classes too, but I only want to detect type functions (or any names that's assigned to one of them (i.e. my_int = int).
The only idea that comes to my mind is checking if X.__name__ is in __builtins__ but I'm not sure if that's a clean nor correct solution.
isinstance(x, (list, dict, set, unicode, str, ...))orx in {list, dict, set, unicode, str, ...}. Out of curiosity, why does it matter if something it a builtin type or not?<type X>instead of<class X>." - that difference completely goes away in Python 3, and it only exists in Python 2 for historical reasons.