how to determine an 'open' string?
Sean 'Shaleh' Perry
shalehperry at attbi.com
Thu May 16 11:06:52 EDT 2002
On 16-May-2002 holger krekel wrote:
> hello,
>
> with my replacement rlcompleter module i'd like to
> have a *correct* check if a string is 'open'.
> examples:
>
> asd"""askdjalsdk # open
> aksdjasd # closed
> asjdkk"kajsd'''' # open
> "'asdasd" # closed
> """dontcountoneven" # open
>
> so i need a function which takes these strings as
> an argument and return 1 for 'open', 0 for a 'closed' string.
>
Seems a really simple solution is count the number of each type of quote in the
string. But first you need to find all of the triple quotes.
for each quote type:
count = find all triple quotes
if count is even: closed
count = find all normal quotes
if count is even: closed
if not closed: open
More information about the Python-list
mailing list