chris from local group
chris from local group

Reputation: 357

Unpack list of strings inside another list of strings

I have found multiple examples about similar questions in SO where they want to flatten a list made of multiple lists e.g [[0,1][2,3][3,4]] into one list. But in my case I just want to unpack one item.

Note I am using the " * " operator that would normally work to expand lists into function arguments in my following example. But, What could I actually use instead the " * " that would unpack my files in this scenario ?

unpack = ["file_1.txt", "file_2.txt", "file_3.txt"]
if unpack:
    subprocess.call(["mv", *unpack, "/destination_path"])

Upvotes: 1

Views: 184

Answers (1)

Mark
Mark

Reputation: 1454

subprocess.call(["mv"] + unpack + ["/destination_path"])

Upvotes: 2

Related Questions