How do you protect yourself from missing comma in vertical string list in python?

前端 未结 4 722
春和景丽
春和景丽 2021-01-12 04:07

In python, it\'s common to have vertically-oriented lists of string. For example:

subprocess.check_output( [
  \'application\',
  \'-first-flag\',
  \'-secon         


        
4条回答
  •  佛祖请我去吃肉
    2021-01-12 04:30

    You can have commas at the end of a line after whitespace, like this:

    subprocess.check_output( [
       'application'           ,
       '-first-flag'           ,
       '-second-flag'          ,
       '-some-additional-flag' ,
    ] )
    

    Doing it that way looks a little worse, but it is easy to spot if you have missed any arguments.

提交回复
热议问题