Skip to content Skip to sidebar Skip to footer

Run Command Line Containing Multiple Strings From Python Script

Hello i am trying to autogenerate a PDF, i have made a python script that generates the wanted PDF but to generate it i have to call my_cover.py -s 'Atsumi' -t 'GE1.5s' -co 'Japan'

Solution 1:

docopt is a great way to do program interfaces, but it would encourage syntax like cover.py --country=Japan --site=Atsumi --turbine=GE15.s (if you want flags).

In my experience docopt makes you rethink your program ideology, what it does and how to achive this. For example, you can experiment with calls like

cover.py cover.pdf --country=Japan --site=Atsumi --turbine=GE15.s
cover.py Japan Atsumi GE15.s

It seems your pdf gerenation is taken care of, but I'd also suggest:

  • get rid on raw_input(), if you can - you are having the command line args anyways
  • split script to functions that do one thing, eg preparing a tex file and writing a pdf file
  • take a use of if __name__ == '__main__':

Post a Comment for "Run Command Line Containing Multiple Strings From Python Script"