webhelpers: howto send an attribute that is not a valid python identifier

9 views
Skip to first unread message

Matt Feifarek

unread,
Jul 3, 2011, 4:32:34 PM7/3/11
to pylons-discuss
Hi there.

I want to make a tag like this:

<form action="go" accept-charset="utf-8" class="goform">

Of course, "accept-charset" is an expression in Python, not a valid identifier. I'm aware that for reserved words, we append an underscore (class -> class_) but is there a proper way to send "accept-charset"?

I ended up with this, but it seems not the nicest way:

tags.form("go", class_="goform", **{'accept-charset':"utf-8"})

Thanks!

Matt Feifarek

unread,
Jul 3, 2011, 8:20:52 PM7/3/11
to pylons-...@googlegroups.com
On Sun, Jul 3, 2011 at 7:00 PM, Mike Orr <slugg...@gmail.com> wrote:
Thatt's the proper way. I suppose we could change it to replace '_' in
the keyword args with '-', if people think it's a generally good idea.

That seems like it might bite you one day in the future. :-)

Mike Orr

unread,
Jul 3, 2011, 8:00:22 PM7/3/11
to pylons-...@googlegroups.com

Thatt's the proper way. I suppose we could change it to replace '_' in


the keyword args with '-', if people think it's a generally good idea.


--
Mike Orr <slugg...@gmail.com>

Eric Ongerth

unread,
Jul 4, 2011, 1:29:49 PM7/4/11
to pylons-discuss
Yeah, seems like that type of auto-replacement doesn't usually turn
out to be the best way forward.
I'm not using webhelpers, though, so I guess that's only a -0.02 from
me on that.

On Jul 3, 5:20 pm, Matt Feifarek <matt.feifa...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages