About 325,000 results
Open links in new tab
  1. parameters - Python: pass arguments to a script - Stack Overflow

    Apr 4, 2014 · You can use the sys module like this to pass command line arguments to your Python script. import sys name_of_script = sys.argv[0] position = sys.argv[1] sample = sys.argv[2] and then your command line would be: ./myscript.py 10 100

  2. python - User input and command line arguments - Stack Overflow

    How do I have a Python script that can accept user input and how do I make it read in arguments if run from the command line?

  3. python - How do I access command line arguments? - Stack …

    To get only the command line arguments (not including the name of the Python file) import sys sys.argv[1:] The [1:] is a slice starting from the second element (index 1) and going to the end of the arguments list. This is because the first element is the …

  4. python - How do I define a function with optional arguments?

    See the Python documentation for an excellent summary; the various other answers to the question make use of most of these variations. Since you always have parameters a, b, c in your example and you appear to call them in a positional manner, you …

  5. python - How can I read and process (parse) command line …

    In Python, how can we find out the command line arguments that were provided for a script, and process them? Related background reading: What does "sys.argv [1]" mean?

  6. What's the best way to parse command line arguments?

    What's the easiest, tersest, and most flexible method or library for parsing Python command line arguments?

  7. python - How to pass an input argument when creating an …

    My idea was to implement the following class: class name (object, name): def __init__ (self, name): print name Then the idea was to create two instances of that class: person1 = name ("

  8. Can a variable number of arguments be passed to a function?

    May 28, 2009 · I have to pass variable number of integer parameters followed by optional string, can I call use xxx (*arg: int, log: str = "") ? The variety in the number of parameters is small 0, 1, 2 or 3, so I can use overloads but it seems like it is not not available in python.

  9. python - Passing a dictionary to a function as keyword parameters ...

    if you'd want this to help others, you should rephrase your question: the problem wasn't passing a dictionary, what you wanted was turning a dict into keyword parameters

  10. How do Python functions handle the types of parameters that you …

    Apr 7, 2017 · # stuff However, you don't actually give the types of those parameters. Also, if I remember, Python is a strongly typed language, as such, it seems like Python shouldn't let you pass in a parameter of a different type than the function creator expected. However, how does Python know that the user of the function is passing in the proper types?

Refresh