Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26770
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'argument': 0.04; 'arguments': 0.07; 'list?': 0.07; 'python': 0.09; 'arguments,': 0.09; 'cc:addr:python-list': 0.10; 'index': 0.13; 'definition.': 0.16; 'sequential': 0.16; 'subject:pass': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'thanks,': 0.18; 'cc:2**0': 0.23; 'bruce': 0.23; 'statement': 0.23; 'cc:no real name:2**0': 0.24; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'separate': 0.27; 'clever': 0.29; 'parameters.': 0.29; 'function': 0.30; 'like:': 0.33; 'turns': 0.33; 'list': 0.35; 'pm,': 0.35; 'something': 0.35; 'there': 0.35; 'does': 0.37; 'listing': 0.37; 'subject:: ': 0.38; 'received:192': 0.39; 'received:192.168': 0.40; 'email addr:gmail.com': 0.63; 'subject:there': 0.65; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84 |
| Date | Wed, 08 Aug 2012 21:07:04 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | bruceg113355@gmail.com |
| Subject | Re: Is there a clever way to pass arguments |
| References | <0aaad6e4-8751-4073-bf9c-14285c1f3422@googlegroups.com> |
| In-Reply-To | <0aaad6e4-8751-4073-bf9c-14285c1f3422@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:nWMESztJEkUx5VxpWaG4DzJuMUJvrTSzhfjkZPggBOj ahXHzmzwXQVcm0kNtPXT4aJaRsAGf9jt1kA4vCoU38NCIxdwxh W1NTyzYruP7nsOpnX0xb3vi4Cou0TlD3/AXaYBSO+o1WRMhG0B 7ihiRfltIPCQZlYN+2okK5H8AN0X30kWYTmGXav3rVkRZZJHDY snsfIEvH2fTl7Ppd656dcXeIuH18MVbP1gaZt6Beianqn+yfn3 lScb3lkvdB7rHDiBdn4UzqkmNT3EWU6p5KpecXfuehKG2vezfR i84IapquI1oq6ywr8A9KKg8CDV5RFsew3wvFZdlsxZAjFA6iQ= = |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | d@davea.name |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3088.1344474457.4697.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1344474457 news.xs4all.nl 6964 [2001:888:2000:d::a6]:59911 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26770 |
Show key headers only | View raw
On 08/08/2012 08:41 PM, bruceg113355@gmail.com wrote:
> Is there a way in Python to pass arguments without listing each argument?
> For example, my program does the following:
>
> testData (z[0], z[1], z[2], z[3], z[4], z[5], z[6], z[7])
>
> Is there a clever way to pass arguments in a single statement knowing that each argument is a sequential index from a list?
> I cannot change the function definition.
>
> Thanks,
> Bruce
If a function is expecting exactly 8 arguments, and z is a list of
length 8, you can call the function like:
testData(*z)
if z is longer, then you'd need something like (untested)
testData(*z[:8])
The * basically turns a list into separate arguments, and these are then
applied to the formal parameters.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is there a clever way to pass arguments bruceg113355@gmail.com - 2012-08-08 17:41 -0700
Re: Is there a clever way to pass arguments Andrew Cooper <amc96@cam.ac.uk> - 2012-08-09 01:47 +0100
Re: Is there a clever way to pass arguments Dave Angel <d@davea.name> - 2012-08-08 21:07 -0400
Re: Is there a clever way to pass arguments bruceg113355@gmail.com - 2012-08-08 18:20 -0700
Re: Is there a clever way to pass arguments bruceg113355@gmail.com - 2012-08-08 18:20 -0700
Re: Is there a clever way to pass arguments Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-09 01:34 +0000
Re: Is there a clever way to pass arguments Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-09 11:05 +0200
Re: Is there a clever way to pass arguments Chris Angelico <rosuav@gmail.com> - 2012-08-09 19:13 +1000
Re: Is there a clever way to pass arguments Alister <alister.ware@ntlworld.com> - 2012-08-09 17:14 +0000
Re: Is there a clever way to pass arguments GangGreene <GangGreene@invalid.com> - 2012-08-09 15:39 -0400
Re: Is there a clever way to pass arguments Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-08-09 11:50 +0200
Re: Is there a clever way to pass arguments Terry Reedy <tjreedy@udel.edu> - 2012-08-09 15:48 -0400
csiph-web