A question about a metacharacter

I

igbt

I am creating a simple script which is using gtk. In this script you
must enter a text, if you do not enter anything or you enter a dot,
the script will be finished. However, if you don't enter anything the
script works but if you enter a dot (.) the script does not work. I
was investigating about it and I think the problem is with the dot
character sss == "." . I was trying the same line with other
metacharacters like *, (, ) ... and I found the same problem. I was
looking for an example where I could see the way I could do it without
any error but I did not find it. Could somebody tell me how can I
solve this error?



sss = entryName.get_text() # The script gets the text
if sss == "" or sss == ".":
gtk.main_quit() #The script finishes


Thanks ; -)
 
C

Chris

I am creating a simple script which is using gtk. In this script you
must enter a text, if you do not enter anything or you enter a dot,
the script will be finished. However, if you don't enter anything the
script works but if you enter a dot (.) the script does not work. I
was investigating about it and I think the problem is with the dot
character  sss == "." .  I was trying the same line with other
metacharacters like *, (, ) ...  and I found the same problem. I was
looking for an example where I could see the way I could do it without
any error but I did not find it. Could somebody tell me how can I
solve this error?

sss = entryName.get_text()      # The script gets the text
        if sss == "" or sss == ".":
                gtk.main_quit()        #The script finishes

Thanks ; -)

try this.

sss = entryName.get_text()
if not sss.strip() or sss.strip() == '.':
gtk.main_quit()

I wouldn't be suprised if your input is being captured with End-Of-
Line characters which would cause the mis-match.
 
I

igbt

try this.

sss = entryName.get_text()
if not sss.strip() or sss.strip() == '.':
gtk.main_quit()

I wouldn't be suprised if your input is being captured with End-Of-
Line characters which would cause the mis-match.

It does not work. Thanks for your help
 
A

ajaksu

However, if you don't enter anything the
script works but if you enter a dot (.) the script does not work.

Have you tried it with other non-metacharacter values?
sss = entryName.get_text()      # The script gets the text
        if sss == "" or sss == ".":
                gtk.main_quit()        #The script finishes

Try adding this:
else:
print sss, type(sss)

Good luck!
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top