python create slice object from string
If you want a slice object, why don't you just instantiate one?
s = slice(start, stop, step)
What are you meaning by "creating it from a string"?
slice(*map(lambda x: int(x.strip()) if x.strip() else None, mystring.split(':')))
for single arg slices '-1'
or '1'
so when mystring.split(':')==1
you just call int(x)
On request, took it out of comment section.
slice(*[{True: lambda n: None, False: int}[x == ''](x) for x in (mystring.split(':') + ['', '', ''])[:3]])