good practice for string.partition in python
- by user1544915
some case i write code like these:
a,temp,b = s.partition('-')
i just need to pick the first and 3rd element. temp would never be used. is there a better way to do this?
the common case is ,a better way to pick separted element to make a new list?
for example
i want to make a new list use old list 0,1,3,7 element
code would be this:
newlist = [oldlist[0],oldlist[1],oldlist[3],oldlist[7]]
it's pretty ugly,isn't it?