def first_every_last(iterable, first, every, last):
 did_first = False
 for item in iterable:
  if (not did_first):
   did_first = True
   first(item)
  every(item)
 if did_first:
  last(item)

def first_every_last ( iterable , first , every , last ) : did_first = False for item in iterable : if ( not did_first ) : did_first = True first ( item ) every ( item ) if did_first : last ( item )
execute something before the first item of iter .