Linked Questions

785 votes
11 answers
998k views

I use python to create my project settings setup, but I need help getting the command line arguments. I tried this on the terminal: $python myfile.py var1 var2 var3 In my Python file, I want to use ...
382 votes
15 answers
420k views

What's the easiest, tersest, and most flexible method or library for parsing Python command line arguments?
34 votes
4 answers
185k views

Is it possible to run first the program then wait for the input of the user in command line. e.g. Run... Process... Input from the user(in command line form)... Process...
31 votes
5 answers
59k views

What would be an easy expression to process command line arguments if I'm expecting anything like 001 or 999 (let's limit expectations to 001...999 range for this time), and few other arguments passed,...
25 votes
6 answers
36k views

from sys import argv script, lira_cbt, [eur_hedge] = argv if eur_hedge == None: #Do x else: #Do y I want it to be able to run with just lira_cbt as an argument (doing x), or with both ...
Felix's user avatar
  • 821
15 votes
3 answers
69k views

I write my scripts in python and run them with cmd by typing in: C:\> python script.py Some of my scripts contain separate algorithms and methods which are called based on a flag. Now I would like ...
10 votes
3 answers
54k views

I have a working code to print random lines from a csv column. #!/usr/bin/python import csv from random import shuffle filename = 'example.csv' col = 2 sample = 100 with open(filename, 'r') as f: ...
4 votes
3 answers
18k views

I am writing a script that controls volume. The name of the script is vv , and it expects one argument. for example vv .9 where .9 is the level you want to set the volume. That program works as ...
4 votes
2 answers
17k views

I am trying to pass a particular directory to a python script and later use that directory in the script . the Directory can be located anywhere. for example, the script should run on the command ...
1 vote
4 answers
6k views

I have a file named myadd.py that contains only the following function: def myadd(a,b): return a+b How can I run it on Linux terminal? I am looking for something easy like this: python myadd 2,3 ...
Albert's user avatar
  • 395
2 votes
3 answers
882 views

Possible Duplicate: Command Line Arguments In Python Example: itp.threads[0].memload(r"c:\FistForSOCAD_PASS.bin","0x108000P") itp.threads[0].cv.cip = "0x108000" itp.go() itp.halt() I would like ...
SeiZai's user avatar
  • 35
1 vote
2 answers
8k views

I have a file.py that I want to pass base_url to when called, so that base_url variable value can be dynamic upon running python file.py base_url='http://google.com' the value of http://google.com ...
John's user avatar
  • 155
1 vote
4 answers
2k views

Currently this is my python script (TagGen) which has one function: def SJtag(file,len_tag): import csv reader = csv.reader(open(file), dialect='excel-tab' ) for row in reader: ...
1 vote
3 answers
2k views

I have this code: #!flask/bin/python import subprocess import types from flask import Flask, jsonify, make_response, abort, request, url_for app = Flask(__name__) @app.route('/v1/kill/process/<...
pyramid13's user avatar
  • 306
1 vote
2 answers
2k views

I have a python script that I'd like to run from the terminal, and it takes about 10 numerical arguments. So far the only way i can think of passing the arguments to the program is as follows: python ...

15 30 50 per page
1
2 3 4 5
...
11