Forgive my ignorance of "*any" notation. I don't have real experience of
using it in my codes so far, and didn't know those parameters were
packed as a tuple:-(


Steven D'Aprano 於 2018/6/3 下午 01:08 寫道:
On Sun, 03 Jun 2018 04:59:34 +0000, Steven D'Aprano wrote:

On Sun, 03 Jun 2018 10:55:04 +0800, Jach Fong 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?

90% of the script you attached is irrelevant to your question. None of
the tkinter or threading code is important. The only important parts
are:

def threaded(action, args, context, onExit, onProgress):
     def progress(*any):
         threadQueue.put((onProgress, any + context))

Here we can tell that ``any`` is a tuple.

Oops, I misread your question. You thought any was an int. But the *
(star) notation in function parameters makes the parameter collect any
unnamed arguments into a single tuple.

def test(first, *args):
     print(args)

test(1, 2, 3, "hello", 99)
=> prints the tuple (2, 3, "hello", 99)




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to