extracting keywords from %(keyword)s-based templates

Daniel Dittmar daniel.dittmar at sap.com
Fri Aug 31 13:29:03 CEST 2001


Try:

class KeywordTrap:
    def __init__ (self):
        self.allwords = {}

    def __getitem__ (self, keyword):
        self.allwords [keyword] = 1
        return 0  # should work for %s and %d

trap = KeywordTrap ()
formatstring % trap
print trap.allwords.keys ()

Daniel






More information about the Python-list mailing list