How can an int be '+' with a tuple?
Gary Herron
gherron at digipen.edu
Sun Jun 3 00:05:19 EDT 2018
In fact, the value of *any* is *not* an integer. The *any notation
causes Python to pack all the arguments into a tuple. This feature is
usually used when there are multiple (and an unknown number) of
parameters, but it works perfectly well with a single parameter.
Here's an example:
>>> def progress(*any):
print(any)
>>> progress(1)
(1,)
>>> progress(1,2,3)
(1, 2, 3)
>>>
On 06/02/2018 07:55 PM, jfong at ms4.hinet.net wrote:
> The attached is a script which can run under Python 3.4/Windows Vista
> correctly. One thing make me puzzled is that the "any + context" at line
> 18. The "any" was passed as an integer from line 43 and the "context"
> was defined as a tuple at line 35. This concatenation works! how?
>
> Best Regards,
> Jach Fong
>
>
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
>
--
Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology
(425) 895-4418
More information about the Python-list
mailing list