how to determine an 'open' string?

Skip Montanaro skip at pobox.com
Thu May 16 13:43:15 EDT 2002


    holger> with my replacement rlcompleter module i'd like to
    holger> have a *correct* check if a string is 'open'.

How about just trying to eval() the string?  Assuming it begins with a
quotation mark or apostrophe it should be safe to call eval().  Either it's
a complete string in which case eval() is safe, or it's an open string and
you get a SyntaxError.  You obviously don't eval stuff that doesn't start
with other characters.

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)
"Excellant Written and Communications Skills required" - seen on chi.jobs





More information about the Python-list mailing list