About 50 results
Open links in new tab
  1. How can I determine a Python variable's type? - Stack Overflow

    Python doesn't have such types as you describe. There are two types used to represent integral values: int, which corresponds to platform's int type in C, and long, which is an arbitrary …

  2. What's the canonical way to check for type in Python?

    Aug 3, 2014 · In Python, you can use the built-in isinstance() function to check if an object is of a given type, or if it inherits from a given type. To check if the object o is of type str, you would …

  3. How to specify multiple types using type-hints - Stack Overflow

    Sep 20, 2025 · I have a function in python that can either return a bool or a list. Is there a way to specify the types using type hints? For example, is this the correct way to do it? def foo (id) -> …

  4. python - Immutable vs Mutable types - Stack Overflow

    Nov 9, 2011 · Mutable types can be changed in place. Immutable types can not change in place. That's the way python sees the world. It is regardless of how variables are passed to functions.

  5. types - How do you set a conditional in python based on …

    I know you can check datatypes in python, but how can you set a conditional based on the datatype? For instance, if I have to write a code that sorts through a dictionary/list and adds up …

  6. python - Determine the type of an object? - Stack Overflow

    Feb 9, 2010 · There are two built-in functions that help you identify the type of an object. You can use type() if you need the exact type of an object, and isinstance() to check an object’s type …

  7. python - How to check what types are in defined types.UnionType ...

    Nov 23, 2022 · Closed 7 months ago. I am using Python 3.11 and I would need to detect if an optional class attribute is type of Enum (i.e. type of a subclass of Enum). With …

  8. python - ctypes - Beginner - Stack Overflow

    I have the task of "wrapping" a c library into a python class. The docs are incredibly vague on this matter. It seems they expect only advanced python users would implement …

  9. types - Complex numbers in python - Stack Overflow

    Dec 3, 2011 · Are complex numbers a supported data-type in Python? If so, how do you use them?

  10. How do Python functions handle the types of parameters that you …

    Apr 7, 2017 · Python doesn't know that you are calling the function with the proper types, and expects the programmer to take care of that. If your function will be called with different types …