1

I am actually trying to give an arrayList (System.Collections.ArrayList) in a powershell script to a python script like this :
Powershell script

    $exampleArray= New-Object System.Collections.ArrayList
    $tabChemins.Add("test1") | Out-Null
    $tabChemins.Add("test2") | Out-Null
    $tabChemins.Add("test3") | Out-Null
    python.exe .\exampleScriptPython.py $exampleArray

Python script : (I don't want to cycle through all the elements using a loop to create my list.)


    import sys
    print(sys.argv[1])
    print(sys.argv[2])
    print(sys.argv[3])


It gives me element by element but I want them in only one element, Output :
test1
test2
test3

Ideal output :
['test1','test2','test3']
2
  • 1
    How about print(sys.argv[1:]) then? i.e., values are passed in fine, your problem seems to be in the way you print them (and I guess a few other things that you might wanna do with them). Commented Jul 1, 2020 at 14:43
  • Thank you @goodvibration it works ! I ask this question because I have multiple arguments to pass in my real powershell script but I think I will just put the array at the end. Commented Jul 1, 2020 at 14:48

1 Answer 1

1

Seems like you can simply use the array sys.argv[1:] for whatever it is that you want to do.

And if you want to pass it to a function as separate arguments, then I believe that *sys.argv[1:] would do the job.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.