[Tutor] this group and one liners
Dennis Lee Bieber
wlfraed at ix.netcom.com
Sat Jul 9 01:23:11 EDT 2022
On Fri, 8 Jul 2022 12:54:02 -0400, <avi.e.gross at gmail.com> declaimed the
following:
>I am not convinced this is fantastic design. The concept of an iterable is
>very powerful but this brings us back to the question we began with. Why not
>have a version of max() that accepts numbers like 1,2,3 as individual
>arguments?
>
>>> max(1, 2, 3)
3
>>>
In the absence of keyword arguments, the non-keyword arguments are
gathered up as a tuple -- which is an iterable.
>>> tpl = (1, 2, 3)
>>> max(tpl)
3
>>> max(*tpl)
3
>>>
First passes single arg tuple. Second /unpacks/ the tuple, passing
three args, which get gathered back into a tuple by max().
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
More information about the Tutor
mailing list