How can an int be '+' with a tuple?
Jach Fong
jfong at ms4.hinet.net
Sun Jun 3 00:35:27 EDT 2018
Yes, (I think) I know the *any usage, but don't know their type will be
changed after unpack?
Gary Herron 於 2018/6/3 下午 12:05 寫道:
> 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
>>
>>
>
More information about the Python-list
mailing list