how to determine an 'open' string?

Bernhard Herzog bh at intevation.de
Fri May 17 05:43:24 EDT 2002


Skip Montanaro <skip at pobox.com> writes:

>     >> How about just trying to eval() the string?  Assuming it begins with
>     >> a quotation mark or apostrophe it should be safe to call eval().
> 
>     Bernhard> If you mean the builtin eval without any form of restricted
>     Bernhard> execution, you're not safe. 
> 
> Whoops!  Thanks.  Them dang paren-less tuples!

I could have used any other expression that can start with a string
literal, like "" + something as in some other postings. The tuple syntax
had the big advantage that it doesn't matter what the part after the
comma evaluates to as long as it doesn't raise any exceptions.


   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                           http://www.mapit.de/



More information about the Python-list mailing list