Top.Mail.Ru
Python
? ?
LiveJournal for python.
View:Personal Journal.
View:Friends.
View:Calendar.
Missed some entries? Then simply jump to the previous day or the next day.

Friday, May 7th, 2004

Time:9:33 am.
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]
Comments: Read 11 orAdd Your Own.

LiveJournal for python.

View:User Info.
View:Friends.
View:Calendar.
View:Memories.
Missed some entries? Then simply jump to the previous day or the next day.

Image