About 17,600,000 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 precision integer (i.e. …

  2. How to set the python type hinting for a dictionary variable?

    Oct 1, 2018 · Python likely derived this naming scheme from C or C++. In C structs are typically lower case (though there are a lot of people that use pascal case), and in C++ people typically use pascal, …

  3. 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, …

  4. python - How should I use the Optional type hint? - Stack Overflow

    Side note: Unless your code only has to support Python 3.9 or newer, you want to avoid using the standard library container types in type hinting, as you can't say anything about what types they must …

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

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

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

  7. What are Python's type "objects" exactly? - Stack Overflow

    Apr 21, 2014 · Python types are ordinary objects just like anything else (everything is an object). Being a type or an instance is a matter of the object's semantics, a role that it plays.

  8. python - How to force/ensure class attributes are a specific type ...

    Mar 29, 2020 · In Python, primitive data types (int, float, str, booleans) are themselves classes. Thus if you instantiate the class attributes of your class before passing the method parameters during object …

  9. 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 …

  10. How can I specify the function type in my type hints?

    Jun 15, 2016 · How can I specify the type hint of a variable as a function type? There is no typing.Function, and I could not find anything in the relevant PEP, PEP 483.