On Tue, Oct 31, 2017 at 10:42:23AM -0200, Joao S. O. Bueno wrote:
> When I need something like this, I usually rop a line on the module
> namespace that goes like:
> 
> first = lambda x: next(iter(x))

That doesn't meet the requirement that x has ONLY one item.

And using lambda like that is bad style. This would be better:

def first(x): return next(iter(x))

and now first has a proper __name__.



-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to