split() off last substring

Max M maxm at mxm.dk
Mon Apr 15 05:29:37 EDT 2002


Noah wrote:

> Can I tell split() to split off the LAST seqment? I guess I want
> something like:
> 
> 	a="aaa.bbb.ccc"
> 	b,c=a.rsplit(1)
> 	print b,c
> 	# "aaa.bbb", "ccc"
> 

It would be esier to just::


 >>> hmm = "aaa.bbb.ccc"
 >>> hmm[hmm.rfind('.')+1:]
'ccc'


regards Max M




More information about the Python-list mailing list