On 08/12/2021 11.07, Chris Angelico wrote: > On Wed, Dec 8, 2021 at 9:04 AM dn via Python-list > <python-list@python.org> wrote: >> >> plus Python, unlike some other languages, allows us to return multiple >> values, either as a collection or as an implied-tuple: >> >> def function_list(): >> a_list = [ i for i in range( 9 ) ] >> return a_list >> >> def function_multiples(): >> a = 1 >> b = 2 >> c = 3 >> return a, b, c >> >> thus: >> >> x, y, z = function_multiples() > > Not sure what you mean by "implied". You're returning a tuple formed > from three values, and then unpacking that into three destinations. > Since, at a technical level, a function can only return one value, > returning a tuple is the standard way to return more than one thing.
How's it going @Chris? (we have another 'overseas-speaker' scheduled for next week's PUG meeting. Rodrigo Girão Serrão will 'beam-in' from Portugal. He presented at EuroPython. His topic with us will be "Python's Objects" - firstly at an intro-level for people who've not built a custom-class previously, and thereafter to more-advanced folk - details upon request...) Back to tuples: You are (strictly) correct. As we both know, a lot of people think that the parentheses 'make' the tuple, whereas in-fact it is the comma-separators. I'd estimate the OP to be in a learning situation/converting-over from another language, so allowance for lax terminology/definitions. -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list