[Tutor] Multiprocessing with many input input parameters
Cameron Simpson
cs at cskk.id.au
Fri Jul 12 19:59:16 EDT 2019
On 11Jul2019 15:40, Mike Barnett <mike_barnett at hotmail.com> wrote:
>If you're passing parameters as a list, then you need a "," at the end of the items. Otherwise if you have something like a string as the only item, the list will be the string.
>
>list_with_one_item = ['item one',]
Actually, this isn't true.
This is a one element list, no trailing coma required:
[5]
Mike has probably confused this with tuples. Because tuples are
delineated with parentheses, there is ambiguity between a tuple's
parentheses and normal "group these terms together" parentheses.
So:
x = 5 + 4 * (9 + 7)
Here we just have parentheses causing the assignment "9 + 7" to occur
before the multiplication by 4. And this is also legal:
x = 5 + 4 * (9)
where the parentheses don't add anything special in terma of behaviour.
Here is a 2 element tuple:
(9, 7)
How does one write a one element tuple? Like this:
(9,)
Here the trailing comma is _required_ to syntacticly indicate that we
intend a 1 element tuple instead of a plain "9 in parentheses") as in
the earlier assignment statement.
I'm not sure any of this is relevant to Sydney's question though.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list