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


Groups > comp.lang.python > #7672

Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?

From Terry Reedy <tjreedy@udel.edu>
Subject Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns?
Date 2011-06-15 00:53 -0400
References <22011833-0833-4589-8326-909f4c57f1aa@a10g2000vbz.googlegroups.com> <mailman.222.1308067590.11593.python-list@python.org> <312107af-ee77-42ff-a8c5-8c32bd2976cf@f11g2000vbx.googlegroups.com> <4DF7AA67.2050100@mrabarnett.plus.com>
Newsgroups comp.lang.python
Message-ID <mailman.257.1308113598.11593.python-list@python.org> (permalink)

Show all headers | View raw


On 6/14/2011 2:37 PM, MRAB wrote:
> On 14/06/2011 18:48, Zach Dziura wrote:
> [snip]
>> I just have one quick question. On the line where you have zip(*arr),
>> what is the * for? Is it like the pointer operator, such as with C? Or
>> is it exactly the pointer operator?
>>
> [snip]
> The * in the argument list of a function call unpacks the following
> list as arguments for the call, for example, zip(*[0, 1, 2]) becomes
> zip(0, 1, 2), so zip(*arr) becomes zip(arr[0], arr[1], ...).
>
> There's also **, which unpacks a dict as keyword arguments.

* and ** in a function call, which distribute arguments,
are essentially the inverse of * and ** in function definitions,
where they say to collect arguments.

-- 
Terry Jan Reedy

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


Thread

What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? Zachary Dziura <zcdziura@gmail.com> - 2011-06-14 08:29 -0700
  Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? Terry Reedy <tjreedy@udel.edu> - 2011-06-14 12:06 -0400
    Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? Zach Dziura <zcdziura@gmail.com> - 2011-06-14 10:48 -0700
      Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? MRAB <python@mrabarnett.plus.com> - 2011-06-14 19:37 +0100
      Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? Terry Reedy <tjreedy@udel.edu> - 2011-06-15 00:53 -0400
  Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? Karim <karim.liateni@free.fr> - 2011-06-14 20:28 +0200
  Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? Ben Finney <ben+python@benfinney.id.au> - 2011-06-15 09:40 +1000
    Re: What is the Most Efficient Way of Printing A Dict's Contents Out In Columns? Chris Angelico <rosuav@gmail.com> - 2011-06-15 10:08 +1000

csiph-web