Skip to content

Instantly share code, notes, and snippets.

@m0xb
Created October 11, 2017 16:30
Show Gist options
  • Select an option

  • Save m0xb/72d5e6aa01381ddadbd9a463b8cfbd04 to your computer and use it in GitHub Desktop.

Select an option

Save m0xb/72d5e6aa01381ddadbd9a463b8cfbd04 to your computer and use it in GitHub Desktop.

Consider the difference between:

  1. Bash command to run a Python script which takes multiple file name arguments:
python script.py file1.txt file2.txt file3.txt
  1. Bash command which runs a Python script multiple times:
for file in file1.txt file2.txt file3.txt; do
    python script.py $file
done

To be similar to the difference between:

def print_many_str(list_of_str):
  for s in list_of_str:
    print(s)

print_many_str(["aaa", "bbb", "ccc"])

and

def print_one_str(my_str):
  print(my_str)

for s in ["aaa", "bbb", "ccc"]:
  print_one_str(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment