About 387,000 results
Open links in new tab
  1. How to define default value if empty user input in Python?

    Here I have to set the default value if the user will enter the value from the keyboard. Here is the code that user can enter value: input = int(raw_input("Enter the inputs : ")) Here the value wi...

  2. python - How to set default value for variable? - Stack Overflow

    Jul 13, 2022 · How to set default value for variable? Asked 9 years, 6 months ago Modified 3 years, 3 months ago Viewed 51k times

  3. python - How do I add default parameters to functions when …

    The empty dict passed as a default parameter is the same dict for every call. So if the function mutates it then the default next time will be the mutated value from last time.

  4. Is there shorthand for returning a default value if None in Python ...

    x or default is an antipattern! It is a frequent source of errors that are hard to debug, because for many subtle reasons x could evaluate to false even if it is the desired value.

  5. python - Return a default value if a dictionary key is not available ...

    Accessing the key and catching the exception is perfectly okay in Python. It is even a well known and oft-used design pattern. If you return None instead, it becomes impossible to store None …

  6. Python argparse: default value or specified value - Stack Overflow

    Jul 14, 2014 · Is there already an action available for this? An example: python script.py --example # args.example would equal a default value of 1 python script.py --example 2 # …

  7. python - Get a function argument's default value? - Stack Overflow

    In python, all the arguments with default value come after the arguments without default value. So the mapping should start from the end till you exhaust the default value list.

  8. How should I declare default values for instance variables in Python?

    However, if I do not require a class variable, but only need to set a default value for my instance variables, are both methods equally good? Or one of them more 'pythonic' than the other? …

  9. python - Setting a Default Value in an Entry box in Tkinter - Stack ...

    Setting a Default Value in an Entry box in Tkinter Asked 10 years, 2 months ago Modified 9 years, 9 months ago Viewed 29k times

  10. default value - Proper way to use **kwargs in Python - Stack …

    Jul 8, 2009 · What is the proper way to use **kwargs in Python when it comes to default values? kwargs returns a dictionary, but what is the best way to set default values, or is there one? …