A question about a metacharacter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • igbt

    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_t ext() # The script gets the text
    if sss == "" or sss == ".":
    gtk.main_quit() #The script finishes


    Thanks ; -)
  • Chris

    #2
    Re: A question about a metacharacter

    On Mar 20, 1:19 pm, igbt <lun...@gmail.c omwrote:
    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_t ext()      # The script gets the text
            if sss == "" or sss == ".":
                    gtk.main_quit()        #The scriptfinishes
    >
    Thanks ; -)
    try this.

    sss = entryName.get_t ext()
    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.

    Comment

    • igbt

      #3
      Re: A question about a metacharacter

      On 20 mar, 12:38, Chris <cwi...@gmail.c omwrote:
      On Mar 20, 1:19 pm, igbt <lun...@gmail.c omwrote:
      >
      >
      >
      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_t ext() # The script gets the text
      if sss == "" or sss == ".":
      gtk.main_quit() #The script finishes
      >
      Thanks ; -)
      >
      try this.
      >
      sss = entryName.get_t ext()
      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

      Comment

      • ajaksu

        #4
        Re: A question about a metacharacter

        On Mar 20, 8:19 am, igbt <lun...@gmail.c omwrote:
        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_t ext()      # 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

        Comment

        Working...