Hi there!
I'm new to learning python and have stumbled on some neat tricks and was wondering what more experienced python programmers though of the following lambda.
# The following anonymous function returns an item from any sequence and
# if not found will return a default value
slice = lambda seq,index,default='': (seq[index:index+1] or [default])[0]
I'm new to learning python and have stumbled on some neat tricks and was wondering what more experienced python programmers though of the following lambda.
# The following anonymous function returns an item from any sequence and
# if not found will return a default value
slice = lambda seq,index,default='': (seq[index:index+1] or [default])[0]
