About 50 results
Open links in new tab
  1. How to declare variable type, C style in Python - Stack Overflow

    Oct 14, 2010 · You're not quite understanding what variables are in Python. Think of it like C void* pointers: they don't have an inherent type, they are names used to refer to, well, anything. In Python, …

  2. Python Variable Declaration - Stack Overflow

    Jun 13, 2012 · I want to clarify how variables are declared in Python. I have seen variable declaration as class writer: path = "" sometimes, there is no explicit declaration but just initializa...

  3. Explicitly declaring a variable type in Python - Stack Overflow

    a = [] a. It gives me all the list functions. similarly with strings I do b=''. But for the file type, I have to use file. and choose the function and write its arguments and then replace file with the variable name. Is …

  4. Explicitly Define Datatype in Python Function - Stack Overflow

    Python is a strongly-typed dynamic language, which associates types with values, not names. If you want to force callers to provide data of specific types the only way you can do so is by adding explicit …

  5. Declare a global variable with certain type - Stack Overflow

    Sep 13, 2019 · 11 In python, is it possible to declare a global variable with a type? I know this is fine to declare a local variable like this.

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

    Oct 1, 2018 · The existing type annotations syntax starts to get very unwieldy when trying to specify complex types and just can't extend to associating a type with a dict key name.

  7. Declaring a strict data type for a variable in Python?

    Here is a class that uses setattr to enforce type. It has a method to assign static type (use int not int() for example) and can also assign type on first assignment of a variable. It is very strict about type but …

  8. Declaring Unknown Type Variable in Python? - Stack Overflow

    Oct 5, 2009 · Python is dynamically typed, you don't need to declare the type of a variable, because a variable doesn't have a type, only values do. (Any variable can store any value, a value never …

  9. Type Hints Convention for Instance Variables Python

    19 @Asara It seems that as of Python 3.8.10 / Mypy 0.910 (Sep 2021), when it comes to distinguishing between a type annotation for an instance variable in a class definition and a declaration for a class …

  10. programming languages - why python doesn't need type declaration …

    Nov 12, 2010 · 1 Python is strongly-typed so a declaring variable's type is unnecessary. (For obvious reasons you must usually still declare variables!) The reason for this is because exceptions are …