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

    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 in …

  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 …

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

  4. python - Immutable vs Mutable types - Stack Overflow

    Nov 9, 2011 · All variables can be reassigned in Python, whether they were previously assigned to mutable or immutable types. However, the behavior of reassignment is different for mutable …

  5. python - Type hints in namedtuple - Stack Overflow

    Dec 14, 2015 · ^ Documentation, discussion, and examples floating around for this syntax is nearly non-existent. I only found it in the cpython typing.py file. It states the syntax is available …

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

  7. Get a list of all the encodings Python can encode to

    Nov 13, 2009 · I am writing a script that will try encoding bytes into many different encodings in Python 2.6. Is there some way to get a list of available encodings that I can iterate over?

  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 …

  9. python - typing.Any vs object? - Stack Overflow

    Oct 2, 2016 · For example, Python's type annotations currently do not support recursive types, which makes typing things like arbitrary JSON dicts difficult. As a temporary measure, you …

  10. strong typing - Is Python strongly typed? - Stack Overflow

    Jul 4, 2012 · A better way to think about strong typing is that type matters when performing operations on a variable. If the type is not as expected, a language that complains is strongly …