Python-equivalent of PHP addslashes/stripslashes functions?

Leeuw van der, Tim tim.leeuwvander at nl.unisys.com
Fri Nov 2 08:16:01 EST 2001


Hi,

I looked at it, but it's only part of the answer. It doesn't provide for an
easy unescape, as for as I can see.
I found, thru reading the list, that the DBAPI provides for escaping of
values sent to the database. That's great, although it doesn't help me with
sending data to other programs. However, the DBAPI and re.escape together
might prove to give me what I want :-)

I found a question from somebody else, in a similar situation to mine, and
like him, I also would like to know of any equivalent to PHP's nice
functions for stripping certain HTML Entitities out of a string.

I'm also looking for something similar to PHP4's session - functions, I'm
writing something simple that works more or less similar with currently a
mysql - backend but with other backends possible (like file, dbm,
postgresql, etc).
If anyone is interested I can post files when they're more complete, but if
there's already something working out there, I'd be happy to use that
instead of continuing my own efforts! :-)

With regards,

--Tim


-----Original Message-----
From: maxm [mailto:maxm at mxm.dk]
Sent: donderdag 1 november 2001 0:06
To: Leeuw van der, Tim
Subject: Re: Python-equivalent of PHP addslashes/stripslashes functions?


http://www.python.org/doc/current/lib/Contents_of_Module_re.html

escape(string)

Return string with all non-alphanumerics backslashed; this is useful if you
want to match an arbitrary literal string that may have regular expression
metacharacters in it.

regards Max m

"Leeuw van der, Tim" <tim.leeuwvander at nl.unisys.com> wrote in message
news:mailman.1004529931.3668.python-list at python.org...
> Hello,
>
> I'd like to know if there's a Python-alternative to the very convenient
PHP
> functions addslashes / stripslashes which add cq remove backslashes to
> things like ', " characters, so that values from HTML forms can be safely
> passed around to other programs, used in SQL statements, etc.
>
> Any pointers?
>
> Thanks in advance,
>
> --Tim
>
>






More information about the Python-list mailing list