HC Library and *attributes parameter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Efrat Regev

    #1

    HC Library and *attributes parameter

    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


  • Peter Hansen

    #2
    Re: HC Library and *attributes parameter

    Efrat Regev wrote:[color=blue]
    > 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?[/color]

    Your guess is pretty close. See here for details:



    -Peter

    Comment

    • Steve Holden

      #3
      Re: HC Library and *attributes parameter

      Efrat Regev wrote:[color=blue]
      > 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?
      >[/color]
      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.
      [color=blue][color=green][color=darkred]
      >>> def f1(a, b, *c):[/color][/color][/color]
      ... print "a:", a
      ... print "b:", b
      ... print "c:", c
      ...[color=blue][color=green][color=darkred]
      >>> f1(1, 2, 3, 4, 5)[/color][/color][/color]
      a: 1
      b: 2
      c: (3, 4, 5)[color=blue][color=green][color=darkred]
      >>> f1('one', 'two')[/color][/color][/color]
      a: one
      b: two
      c: ()[color=blue][color=green][color=darkred]
      >>>[/color][/color][/color]

      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

      Comment

      • Efrat Regev

        #4
        Re: HC Library and *attributes parameter


        "Efrat Regev" <efrat_regev@ya hoo.com> wrote in message
        news:5padnc5DoZ vl66zfRVn-vA@adelphia.com ...[color=blue]
        > Hello,
        > ...[/color]

        Many thanks for the useful replies!!


        Comment

        Working...