| | |
Testing if an object's type is builtin
![]() |
•
•
Join Date: Mar 2007
Posts: 110
Reputation:
Solved Threads: 31
1
#2 Oct 21st, 2009
•
•
•
•
Does anyone know how I can test if an object's type is a builtin type or a user defined type ?
Python Syntax (Toggle Plain Text)
>>> getattr(list, '__module__') '__builtin__' >>>
0
#3 Oct 22nd, 2009
Yes, it's a good idea, for the most basic types. In fact the question is ambiguous. Types defined in C extension modules are not detected with this method. For example
but in fact the deque type lives in a C library
python Syntax (Toggle Plain Text)
>>> from collections import deque >>> print(deque.__module__) collections
_collections.so . I don't know how to detect this automatically. ![]() |
Similar Threads
- error-`void*' is not a pointer-to-object type (C++)
- Convert Object type to DataTime? (C#)
- User declared object type? (C++)
- Convert object of type string to a string (C++)
- Element is undefined in a Java object of type class [Ljava.lang.String; referenced as (ColdFusion)
Other Threads in the Python Forum
- Previous Thread: Faster "single stepping"
- Next Thread: Helping users using object oriented design and code.
| Thread Tools | Search this Thread |






