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

HC Library and *attributes parameter

P: n/a
Hello,

I'm a really new (and quite bad) Python programmer. While trying to use
the HC HTML-Generating library, I couldn't figure out how to set a table's
width to some given width. Moreover, the constructors interface is

def __init__(self, object = None, align = None, border = None, cellspacing =
None, cellpaddding = None, *attributes)

So, what does *attribute stand for (being a C++ programmer, it looks
like a pointer, probably not the case). Is it like the C++ ellipsis? If so,
how can
I use it?

Thanks,

Efrat
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Efrat Regev wrote:
def __init__(self, object = None, align = None, border = None, cellspacing =
None, cellpaddding = None, *attributes)

So, what does *attribute stand for (being a C++ programmer, it looks
like a pointer, probably not the case). Is it like the C++ ellipsis? If so,
how can
I use it?


Your guess is pretty close. See here for details:

http://docs.python.org/ref/calls.html#calls

-Peter
Jul 18 '05 #2

P: n/a
Efrat Regev wrote:
Hello,

I'm a really new (and quite bad) Python programmer. While trying to use
the HC HTML-Generating library, I couldn't figure out how to set a table's
width to some given width. Moreover, the constructors interface is

def __init__(self, object = None, align = None, border = None, cellspacing =
None, cellpaddding = None, *attributes)

So, what does *attribute stand for (being a C++ programmer, it looks
like a pointer, probably not the case). Is it like the C++ ellipsis? If so,
how can
I use it?

The notation "*attribute" in the function signature denotes a variable
number of positional arguments, which are provided to the function body
as a tuple named attribute.
def f1(a, b, *c): ... print "a:", a
... print "b:", b
... print "c:", c
... f1(1, 2, 3, 4, 5) a: 1
b: 2
c: (3, 4, 5) f1('one', 'two') a: one
b: two
c: ()


Much easier than varargs in C!

The notation **kw similarly denotes a variable number of keyword
arguments, which are provided to the function body as a dictionary named kw.

regards
Steve

Jul 18 '05 #3

P: n/a

"Efrat Regev" <ef*********@yahoo.com> wrote in message
news:5p********************@adelphia.com...
Hello,
...


Many thanks for the useful replies!!
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.