good practice for string.partition in python
Posted
by
user1544915
on Stack Overflow
See other posts from Stack Overflow
or by user1544915
Published on 2012-08-29T03:24:40Z
Indexed on
2012/08/29
3:38 UTC
Read the original article
Hit count: 114
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?
© Stack Overflow or respective owner