Fwd: Strange location for a comma

Vladimir Ignatov kmisoft at gmail.com
Thu Sep 3 14:50:54 CEST 2015


>>
>> # On appelle la fonction setup
>> setup(
>>    name = "salut",
>>    version = "0.1",
>>    description = "Ce programme vous dit bonjour",
>>    executables = [Executable("salut.py")],    #  <--- HERE
>> )
>>
>>
>
> Ok its understood, it's a 1 element only tuple
>
> example:
>
>>>> A = 5,
>>>> A
>
> (5,)
>
>>>> A = (6)
>>>> A
>
> 6

No. It's not a tuple in your case (calling 'setup' function)

a = 1,2,  # <- extra comma
print a
b = 1,   # <- extra comma
print b

=>

(1, 2)  # ignored
(1,)    # made tuple

and

def f(a, b):
    print a,b

f(1,2,)   # <- extra comma

=>

1 2  # ignored

Under some circumstances python ignores "excess" comma. At least
inside list definition [1,2,3,]  and function calls f(1,2,)

Vladimir

http://itunes.apple.com/us/app/python-code-samples/id1025613117


More information about the Python-list mailing list