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

    Dec 31, 2008 · How to determine the variable type in Python? So if you have a variable, for example: one = 1 You want to know its type? There are right ways and wrong ways to do just about everything …

  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 use the …

  3. python - 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) -> list or b...

  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 datatypes ...

    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 all the integers, …

  6. 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?

  7. types - What does typing.cast do in Python? - Stack Overflow

    Jul 21, 2018 · import typing type (typing.cast (int, '11')) still returns <class 'str'> instead of int. Then, what does typing.cast do here?

  8. python - ctypes - Beginner - Stack Overflow

    I have the task of &quot;wrapping&quot; 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 ctypes. Some s...

  9. python - What are the differences between type () and isinstance ...

    To summarize the contents of other (already good!) answers, isinstance caters for inheritance (an instance of a derived class is an instance of a base class, too), while checking for equality of type …

  10. python - How to know function return type and argument types?

    202 While I am aware of the duck-typing concept of Python, I sometimes struggle with the type of arguments of functions, or the type of the return value of the function. Now, if I wrote the function …