how to parse sys.argv as dynamic parameters to another function?
Ned Batchelder
ned at nedbatchelder.com
Fri Jan 30 14:05:11 EST 2015
On 1/30/15 11:28 AM, Ian Kelly wrote:
> On Fri, Jan 30, 2015 at 9:09 AM, Robert Chen <robertchen117 at gmail.com> wrote:
>> how to parse sys.argv as dynamic parameters to another function?
>>
>>
>> fun(sys.argv)
>>
>> in perl, this is very easy. please help.
>
> Do you mean that you want each item of sys.argv to be passed as a
> separate parameter to the function? If so, then:
>
> fun(*sys.argv)
>
Robert, this will work, but keep in mind that sys.argv is a list of
strings, always. If your function is expecting integers, you will have
to do an explicit conversion somewhere.
--
Ned Batchelder, http://nedbatchelder.com
More information about the Python-list
mailing list