By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,562 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,562 IT Pros & Developers. It's quick & easy.

What does "*list" mean?

P: n/a
What exactly does "*values" mean in the following code? Is this a
pointer to a PyList? Why can I not find good documentation on this any
where? I must be blind:
from struct import *
format = "dl"
values = [3.14, 42]
foo = pack(format, *values)
foo '\x1f\x85\xebQ\xb8\x1e\t@*\x00\x00\x00' unpack(format, foo) (3.1400000000000001, 42)


More importantly still, how would you write the same code in C? If you
wanted to instead call struct_pack(PyObject *tuple), what would the
tuple look like in C?

Thanks to anyone who can clear all this up for me.

Greg
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Greg Smethells wrote:
What exactly does "*values" mean in the following code? Is this a
pointer to a PyList? Why can I not find good documentation on this any
where? I must be blind:


Just two days ago I had the same qustion, and I got this as answer from
Raymond Hettinger:

http://www.python.org/dev/doc/devel/ref/calls.html

Regarding your C question: I didn't do such a thing, but *list only makes
the items of list be used as distinct arguments - so its more a matter of
the function signature you're calling. I'm sure you'll find something about
variable list arguments somewhere - that means that you function looks like
this:

def foo(arg1, arg2, *args):
....

Diez
Jul 18 '05 #2

P: n/a
"Raymond Hettinger" <vz******@verizon.net> wrote in message
news:mf***************@nwrdny01.gnilink.net...
Hmm, it sounds like the *args calling format
needs to be added to the tutorial.
Raymond Hettinger


And also added to the index of the reference manual! I remember trying
to figure it out the first time that I ran into it - it's pretty
frustrating to not be able to look up these kinds of 'special' symbols.

-- Greg

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.