transforming a list into a string
Christopher T King
squirrel at WPI.EDU
Mon Aug 2 02:05:33 CEST 2004
On Sun, 1 Aug 2004, Tim Peters wrote:
> [Christopher T King]
> > ...
> > Curious, why isn't slicing of generators defined, using islice(), so "it1
> > = iter(items)[0::2]" is valid?
> If only some iterators implement it (like generator-iterators), then the
> general interchangeability of iterable objects we enjoy today would be
> damaged too.
Ah, I see your point. But most functions that expect iterators use iter()
on them first (to iterize sequences), do they not? So long as iter()
supplies the necessary __getslice__ implementation, the world would be
happy. This situation would mirror the situation with list(): though a
user-defined sequence might not implement __getslice__ (and still be
usable as a list), the object returned by list() is guaranteed to.
More information about the Python-list