help please

rzed rzantow at ntelos.net
Mon Feb 21 11:03:34 EST 2005


"gargonx" <gargonx at gmail.com> wrote in message
news:1108959170.585091.202240 at z14g2000cwz.googlegroups.com...
> 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
{}







More information about the Python-list mailing list