split twice in the same expression?

Posted by UcanDoIt on Stack Overflow See other posts from Stack Overflow or by UcanDoIt
Published on 2008-11-27T16:12:04Z Indexed on 2010/04/12 23:12 UTC
Read the original article Hit count: 244

Filed under:
|

Imagine I have the following:

inFile = "/adda/adas/sdas/hello.txt"

# that instruction give me hello.txt
Name = inFile.name.split("/") [-1]

# that one give me the name I want - just hello
Name1 = Name.split(".") [0]

Is there any chance to simplify that doing the same job in just one expression?

© Stack Overflow or respective owner

Related posts about python

Related posts about beginner