Tuesday, October 18, 2016

More python lamda

Little parsing short cut I try in python command shell:

>>>  DLim = lambda x,y : x.find(y,0,len(x))
>>>  Atom = lambda x,y : x[0:DLim(x,y)]
>>>  Atom("Hello","o")
'Hell'
>>>  Atom("Hello","l")
'He'
>>>

The Atom lamda returns the first string delimited by some given character.

No comments: