list comprehensions value assignment syntax error
Sean Ross
sross at connectmail.carleton.ca
Tue Jan 7 20:00:41 EST 2003
More information about the Python-list mailing list
Tue Jan 7 20:00:41 EST 2003
- Previous message (by thread): list comprehensions value assignment syntax error
- Next message (by thread): list comprehensions value assignment syntax error
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
you could try: L = [chr(i) for i in range(256)] this should work so long as len(L) == 256 before this assignment statement "Gerrit Holl" <gerrit at nl.linux.org> wrote in message news:mailman.1041983459.23262.python-list at python.org... > Hi, > > I am trying to assign to a list item using list comprehensions, but this > raises a SyntaxError: > > >>> [l[i] = chr(i) for i in range(256)] > File "<stdin>", line 1 > [l[i] = chr(i) for i in range(256)] > ^ > SyntaxError: invalid syntax > > Why? > > Do I really have to abandon list comprehensions or do this?: > > >>> [l.__setitem__(i, chr(i)) for i in range(256)] > > yours, > Gerrit. > > -- > Asperger Syndroom - een persoonlijke benadering: > http://people.nl.linux.org/~gerrit/ > Het zijn tijden om je zelf met politiek te bemoeien: > http://www.sp.nl/ >
- Previous message (by thread): list comprehensions value assignment syntax error
- Next message (by thread): list comprehensions value assignment syntax error
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list