why generator assigned to slice?

ana sanchez private at private.com
Wed Jan 5 08:51:35 EST 2011






hi!!!

i found this when i read the source of a program in python:

        self.__chunks[start:end] = (chunk for i in xrange(start, end))

and also this:

        self.__lines[line:line] = (None for i in xrange(count))

what utility has to assign a generator to a slice???  ?the *final
result* isn't the same as this?:

        self.__chunks[start:end] = [chunk for i in xrange(start, end)]

        self.__chunks[line:line] = [None for i in xrange(count)]

thanks!!!

ana

p.d. excuse my english



More information about the Python-list mailing list