473,382 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

A question about a metacharacter

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
3 1287
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
8
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: eScrewDotCom | last post by:
www.eScrew.com eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is...
0
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
7
by: Edward Yang | last post by:
A few days ago I started a thread "I think C# is forcing us to write more (redundant) code" and got many replies (more than what I had expected). But after reading all the replies I think my...
1
by: Peng Yu | last post by:
Hi, '\b' only match the boundary between alphanumerical char and nonalphanumerical char. I'm wonder if there is a generic metacharacter to match the boundary between any non intersected char set...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.