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: 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 Subject: Re: how to parse sys.argv as dynamic parameters to another function? Date: Fri, 30 Jan 2015 14:05:11 -0500 References: 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: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On 1/30/15 11:28 AM, Ian Kelly wrote: > On Fri, Jan 30, 2015 at 9:09 AM, Robert Chen 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