[EMAIL PROTECTED] ha scritto: > Hello everyone, > > I have written this small utility function for transforming legacy > file to Python dict: > > > def lookupdmo(domain): > lines = open('/etc/virtual/domainowners','r').readlines() > lines = [ [y.lstrip().rstrip() for y in x.split(':')] for x in > lines] > lines = [ x for x in lines if len(x) == 2 ] > d = dict() > for line in lines: > d[line[0]]=line[1] > return d[domain] >
cache = None def lookup( domain ): if not cache: cache = dict( [map( lambda x: x.strip(), x.split(':')) for x in open('/etc/virtual/domainowners','r').readlines()]) return cache.get(domain) Glauco -- http://mail.python.org/mailman/listinfo/python-list