Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84915

Re: how to parse sys.argv as dynamic parameters to another function?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'explicit': 0.07; 'perl,': 0.07; 'parameter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.12; 'expecting': 0.16; 'function?': 0.16; 'integers,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'robert,': 0.16; 'somewhere.': 0.16; 'subject:parameters': 0.16; 'wrote:': 0.18; 'work,': 0.20; 'help.': 0.21; 'separate': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'robert': 0.30; 'another': 0.32; 'fri,': 0.33; 'but': 0.35; 'subject:?': 0.36; 'so,': 0.37; 'list': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'ian': 0.60; 'conversion': 0.61; '30,': 0.65; 'charset:windows-1252': 0.65; '2015': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ned Batchelder <ned@nedbatchelder.com>
Subject Re: how to parse sys.argv as dynamic parameters to another function?
Date Fri, 30 Jan 2015 14:05:11 -0500
References <baa4011f-0745-4f8b-a6f5-fc242a886d78@googlegroups.com> <CALwzid=2xNRdfCkJY9terZoZ1Ep385Y7-ESmoBLBKPQw0ZEgYA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 18.111.27.119
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
In-Reply-To <CALwzid=2xNRdfCkJY9terZoZ1Ep385Y7-ESmoBLBKPQw0ZEgYA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18318.1422644725.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1422644725 news.xs4all.nl 2930 [2001:888:2000:d::a6]:33514
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:84915

Show key headers only | View raw


On 1/30/15 11:28 AM, Ian Kelly wrote:
> On Fri, Jan 30, 2015 at 9:09 AM, Robert Chen <robertchen117@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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

how to parse sys.argv as dynamic parameters to another function? Robert Chen <robertchen117@gmail.com> - 2015-01-30 08:09 -0800
  Re: how to parse sys.argv as dynamic parameters to another function? Skip Montanaro <skip.montanaro@gmail.com> - 2015-01-30 10:16 -0600
  Re: how to parse sys.argv as dynamic parameters to another function? Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 09:28 -0700
  Re: how to parse sys.argv as dynamic parameters to another function? Ned Batchelder <ned@nedbatchelder.com> - 2015-01-30 14:05 -0500

csiph-web