[Zope] Removing " 's from strings

Thomas B. Passin tpassin@mitretek.org
Tue, 20 Nov 2001 10:51:29 -0500


[Peter Armstrong]

>
> I'm trying to make an id from a string, but the string has " on each end
of
> it, and I can't find a way to get rid of them in Zope.
>
> I thought of something like:
> <dtml-call "REQUEST.set('thing', _.string.translate(thestring,
> _.string.maketrans('',''), '"'))">
>
> But that seems to treat it as the start of a piece of text, and so then
> thinks that the dtml-let I have just before that line doesn't have a
closing
> tag!
>
> A way to use the url_quote parameter at the same time as setting it's
value
> in the REQUEST thingy would be good, but I don't how to work it.
>

If the extra quote characters are literally the first and last things in the
string, you could use

str[1:-1]

where "str" is the original value.  That bit of Python syntax will chop off
the first and last characters.

Cheers,

Tom P