By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 935 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

A question about a metacharacter

P: n/a
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 ; -)
Mar 20 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Mar 20, 1:19*pm, igbt <lun...@gmail.comwrote:
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 scriptfinishes

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.
Mar 20 '08 #2

P: n/a
On 20 mar, 12:38, Chris <cwi...@gmail.comwrote:
On Mar 20, 1:19 pm, igbt <lun...@gmail.comwrote:
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.
It does not work. Thanks for your help
Mar 20 '08 #3

P: n/a
On Mar 20, 8:19*am, igbt <lun...@gmail.comwrote:
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 scriptfinishes
Try adding this:
else:
print sss, type(sss)

Good luck!
Daniel
Mar 20 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.