Open
Description
Moving discussion from PR #222 here. (link to the thread)
First, have an __gettitem__
method
from itertools import islice
.
.
.
def __getitem__(self, arg):
if isinstance(arg, slice):
return islice(self, arg.start, arg.stop, arg.step)
elif isinstance(arg, int):
return list(islice(self, arg, arg + 1, 1))[0]
else:
raise TypeError
Second, make it so ConfigSet
can be constructed from an arbitrary iterable.
This came from wanting a (slightly) simpler interface, where ConfigSet behaves more like a list:
subsample_configset = ConfigSet(in_configset[::2])
Currently that can be done by converting to list and back
subsample_configset = ConfigSet(list(in_configset)[::2])
Not sure if this simpler interface is worth the changes, but being able to create ConfigSet
s from arbitrary iterable/generator might be useful?