Thread: Dictionary Help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

    Dictionary Help


    Hi
    I am trying to write a set of pretty printers for the Qt framework
    My python script declares a dictionary as

    Code:
    def build_dictionary ():
        pretty_printers_dict[re.compile('^QDate*$')] = lambda val: QDatePrinter(val,"true")
    
    pretty_printers_dict = {}
    
    build_dictionary ()
    Then I have a search routine that should find the string QDate*
    in this extract typename is set to "QDate*"

    Code:
        for function in pretty_printers_dict:
            if function.search (typename):
                return pretty_printers_dict[function] (val)
    But no match is found

    Could someone please help me and explain why this is?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Joensuu, Finland
    Posts
    428
    Rep Power
    66
    Originally Posted by grahamlabdon
    Could someone please help me and explain why this is?
    The regex “^QDate*$” doesn’t match the string “QDate*” but it does match “QDate”, “QDatee”, “QDateeeeeee” and so on.

    You probably meant either “^QDate.*$” (strings starting QDate) or “^QDate\*$” (exactly the string “QDate*”).
    My armada: openSUSE 13.1 (home desktop, home laptop), Crunchbang Linux 11 (mini laptop, work laptop), Android 4.2.1 (tablet)
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    Thanks
    I'll give it a try

IMN logo majestic logo threadwatch logo seochat tools logo