Kartic <[EMAIL PROTECTED]> wrote: ... > I am not sure what book you are using but I don't think it is a very > good one.
Hmmm, considering he said it's "Python in a Nutshell", I disagree with you;-). If he had understood that he probably wanted to use lists, not arrays, the top paragraph on p. 47 might have helped him -- "Assigning to an item with an invalid index also raises an exception", and list comprehensions are on p. 56. But considering that in the first post he was just trying to assign to an indexing on a name he had never bound at all, it seems to me that starting with the Nutshell may simply have been a bit of "running before you can walk". The Nutshell does mention that names (variables) spring into existence when you bind them, which implies they don't exist previously, and thus you can't perform any operation on them (such as binding an indexing on them) before you're bound them; but the Nutshell doesn't extensively belabor the point. I tried to explain this issue to another poster who recently appeared to want to turn the Nutshell into a lay version of the Heart Sutra ("Therefore, Shariputra, in Python there are no declarations. There is no use strict, no option explicit, no implicit none; no type of a name and no declaring of a name so that it can't be rebound, no defining of a name's type and no omitting to define a name's type, ..."). In a quick reference, there just isn't enough space to repeat every key point, much less to belabor the implications of each; even if space were free, having to skip through such repetitions would _waste_ time for the main target audience -- people who know some Python and want to get reminded of every detail about a certain subject, or just look up something specific. Trying to make a book that's both a hand-holding tutorial _and_ a quick reference would produce a book that is not very good at either task, IMHO. Alex -- http://mail.python.org/mailman/listinfo/python-list