Converting = to ==
Moshe Zadka
moshez at math.huji.ac.il
Fri Apr 28 01:06:58 EDT 2000
On Thu, 27 Apr 2000, Warren Postma wrote:
> I have an "end user query tool" that uses Python expressions, but I want
> comparisons to be able to be written either as A=B or A==B then I want to
> compare them using Python's Eval function.
Try using the tokenize model to tokenize the string, and replacing "="
with "==" at the token level. This will also gurrantee you won't be fooled
by strings containing "=" or other evils.
--
Moshe Zadka <mzadka at geocities.com>.
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com
More information about the Python-list
mailing list