Created
April 30, 2019 15:41
-
-
Save envil/d3486ce742b0ea8c8cfc79c991364920 to your computer and use it in GitHub Desktop.
kwargs for python running via cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
# RUN: | |
# python main.py fd_min=100 fd_max=250 sd_min=20 sd_max=50 vel_min=30 vel_max=100 sam_freq=50 X=1024 Y=768 dist=60 size=53.34 | |
def main(): | |
kwargs_raw = sys.argv[1:] | |
kwargs = {key: val for key, val in (a.split('=', 1) for a in kwargs_raw)} | |
print(kwargs) | |
if __name__ == '__main__': | |
main() | |
''' | |
Output: | |
{'fd_min': '100', 'fd_max': '250', 'sd_min': '20', 'sd_max': '50', 'vel_min': '30', 'vel_max': '100', 'sam_freq': '50', 'X': '1024', 'Y': '768', 'dist': '60', 'size': '53.34'} | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment