help please

S

Steven Bethard

Dennis said:
decode_replacements.update([(std[key], key) for key in std])

Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: keys

Did you read the reference manual?

Yes, actually. But I generally check only the reference manual for the
current version of Python:

http://docs.python.org/lib/typesmapping.html

which does support sequence arguments for dict.update. As noted there,
of course, this support was added for Python 2.4.

STeVe
 
R

rzed

gargonx said:
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):
{}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,219
Messages
2,571,127
Members
47,744
Latest member
FrederickM

Latest Threads

Top