Skip to content

Instantly share code, notes, and snippets.

View thewickedaxe's full-sized avatar

Srinivas Suresh Kumar thewickedaxe

View GitHub Profile
@thewickedaxe
thewickedaxe / argparse-dynamic.py
Created August 2, 2017 16:50
Dynamic args in argparse
parser=argparse.ArgumentParser()
parser.add_argument('-k','--kwarg',nargs=3,action='append')
args=parser.parse_args('-k mass 100 inf -k spin 0.5 1.0'.split())
Namespace(kwarg=[['mass', '100', 'inf'], ['spin', '0.5', '1.0']])
they could be converted to a dictionary with an expression like:
vargs={key:(float(v0),float(v1)) for key,v0,v1 in args.kwarg}
which could be passed to your function as:
@Huarong
Huarong / parse_cmd_args.py
Last active December 23, 2016 01:21
Python: parse command arguments with argparse module example
def parse_cmd_args():
parser = argparse.ArgumentParser(description='run the procedure of advice opinion extraction')
parser.add_argument('config', help='config file path')
parser.add_argument('-b', '--begin', type=int, default=-1, help='The process step to begin')
parser.add_argument('-e', '--end', type=int, default=-1, help='The process step to end')
parser.add_argument('-t', '--test', action='store_true', help='Indicate test or not')
args = parser.parse_args()
return args
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active March 18, 2026 09:53
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname