Syntax for class keyword in HTMLgen

Jp Calderone exarkun at intarweb.us
Fri Feb 21 01:42:34 EST 2003


On Thu, Feb 20, 2003 at 10:00:43PM -0800, sgtpepper wrote:
> Relatively new to Python, so be gentle.
> 
> What is the proper syntax for the 'class' keyword in HTMLgen?
> 
> div = Div( style="color:white;" )
> # expected HTML <DIV style="color:white;"></DIV>
> 
> div = Div( align="left", class="myclass" )
> # hoped-for HTML <DIV align="left" class="myclass"></DIV>
> 
> I get 'Syntax error:  invalid syntax' with the error 'pointer'
> pointing to the 'c' in 'class' since it is a reserved keyword.

  This works:

    div = Div(**{'align': 'left', 'class': 'myclass'})

  (Well, I say it works, but I don't know much about HTMLgen).
  The ** syntax is described here (somewhat cryptically):

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

  Jp



-- 
A sad spectacle.  If they be inhabited, what a scope for misery 
and folly.  If they be not inhabited, what a waste of space.
                -- Thomas Carlyle, looking at the stars
-- 
 up 12 days, 10:28, 4 users, load average: 0.41, 0.36, 0.29
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030221/2e4fcf52/attachment.sig>


More information about the Python-list mailing list