switch recipe?

Mark McEahern mark at mceahern.com
Fri Jul 12 16:37:23 EDT 2002


> or possibly:
> 
>  def make_switch(*args):
>       """Return a generator that loops through args."""
>       if not args:
>           raise RuntimeError("Missing parameter: args.")
>       def switch():
>           while True:
>               for a in args:
>                  yield a
>       return switch

Holy cow, that's much nicer!

Thanks,

// mark
-






More information about the Python-list mailing list