On Thursday 04 October 2007 5:07:51 pm Stefan Arentz wrote: > Is there a better way to do the following? > > attributes = ['foo', 'bar'] > > attributeNames = {} > n = 1 > for attribute in attributes: > attributeNames["AttributeName.%d" % n] = attribute > n = n + 1 > > It works, but I am wondering if there is a more pythonic way to > do this. > > S.
just curious. why are you bothering in creating a dictionary? why not just iterate over attributes? why duplicate it and make it bigger? I personally think the dictionary is unnecessary but I may be wrong. anyhow, I keep getting "SyntaxError: Non-ASCII character '\xc2'..." on line 5. anyone know what this is? I couldn't run the script but from looking at it, it appears you're making some pointless keys when indexes may be better. -- Best Regards Victor B. Gonzalez
pgpvW9I2kM7nD.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list