"gargonx" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Even if i put it in exactly the way you did: > > >>> import re > >>> charmatcher = re.compile(r' [A-Z] [\d]?') > >>> > >>> ext = dict(D="V1", O="M1", G="S1") > >>> std = dict(S="H") > >>> > >>> decode_replacements ={} > >>> decode_replacements.update([(std[key], key) for key in std]) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > AttributeError: keys
Works with 2.4, but not with 2.3.4: Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> charmatcher = re.compile(r' [A-Z] [\d]?') >>> >>> ext = dict(D="V1", O="M1", G="S1") >>> std = dict(S="H") >>> >>> decode_replacements ={} >>> decode_replacements.update([(std[key], key) for key in std]) >>> >>> print decode_replacements {'H': 'S'} Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> charmatcher = re.compile(r' [A-Z] [\d]?') >>> >>> ext = dict(D="V1", O="M1", G="S1") >>> std = dict(S="H") >>> >>> decode_replacements ={} >>> decode_replacements.update([(std[key], key) for key in std]) Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: keys >>> >>> print decode_replacements {} -- http://mail.python.org/mailman/listinfo/python-list