Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #95927

Re: Strange location for a comma

Path csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '+++': 0.03; 'skip:[ 20': 0.03; 'diff': 0.05; 'executable': 0.07; 'ast': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thx': 0.09; 'tuple': 0.09; 'example:': 0.10; 'def': 0.13; '+1,11': 0.16; '-1,9': 0.16; 'comma': 0.16; 'comma,': 0.16; 'executables': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.16; 'element': 0.18; '>>>': 0.20; '+0200': 0.20; 'setup,': 0.22; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'function': 0.28; '---': 0.28; 'cat': 0.29; 'program,': 0.29; 'add': 0.34; 'there': 0.36; 'smaller': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'no,': 0.38; 'version': 0.38; 'end': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'hello,': 0.40; 'vous': 0.61; 'dont': 0.64; 'dans': 0.72; 'skip:n 40': 0.72; 'subject:location': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Strange location for a comma
Date Thu, 03 Sep 2015 14:48:03 +0200
Organization None
References <55e83afb$0$3157$426a74cc@news.free.fr> <55e83ce3$0$3327$426a74cc@news.free.fr>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Gmane-NNTP-Posting-Host p57bd91c6.dip0.t-ipconnect.de
User-Agent KNode/4.13.3
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.61.1441284505.8327.python-list@python.org> (permalink)
Lines 93
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441284505 news.xs4all.nl 23828 [2001:888:2000:d::a6]:39427
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:95927

Show key headers only | View raw


ast wrote:

> 
> "ast" <nomail@invalid.com> a écrit dans le message de
> news:55e83afb$0$3157$426a74cc@news.free.fr...
>> Hello,
>> At the end of the last line of the following program,
>> there is a comma, I dont understand why ?
>>
>> Thx
>>
>>
>> from cx_Freeze import setup, Executable
>>
>> # 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, in a function call an extra comma has no effect:

>>> def f(x): return x
... 
>>> f(42)
42
>>> f(42,)
42
>>> f(x=42)
42
>>> f(x=42,)
42

The only reason I see to add an extra comma are smaller and easier to read 
diffs when you make a change:

$ cat before.py
func(
    arg_one=1,
    arg_two=2
)

func(
    arg_one=1,
    arg_two=2,
)
$ cat after.py
func(
    arg_one=1,
    arg_two=2,
    arg_three=3
)

func(
    arg_one=1,
    arg_two=2,
    arg_three=3,
)
$ diff -u before.py after.py
--- before.py   2015-09-03 14:44:27.709735075 +0200
+++ after.py    2015-09-03 14:44:55.275958331 +0200
@@ -1,9 +1,11 @@
 func(
     arg_one=1,
-    arg_two=2
+    arg_two=2,
+    arg_three=3
 )
 
 func(
     arg_one=1,
     arg_two=2,
+    arg_three=3,
 )

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Strange location for a comma "ast" <nomail@invalid.com> - 2015-09-03 14:20 +0200
  Re: Strange location for a comma "ast" <nomail@invalid.com> - 2015-09-03 14:28 +0200
    Re: Strange location for a comma Peter Otten <__peter__@web.de> - 2015-09-03 14:48 +0200
    Re: Strange location for a comma MRAB <python@mrabarnett.plus.com> - 2015-09-03 13:50 +0100
    Fwd: Strange location for a comma Vladimir Ignatov <kmisoft@gmail.com> - 2015-09-03 08:50 -0400
    Re: Strange location for a comma Tim Chase <python.list@tim.thechases.com> - 2015-09-03 09:36 -0500
    Re: Strange location for a comma Martin Komoň <martin@mkomon.cz> - 2015-09-03 14:34 +0200
  Re: Strange location for a comma Laura Creighton <lac@openend.se> - 2015-09-03 14:40 +0200
  Re: Strange location for a comma "ast" <nomail@invalid.com> - 2015-09-03 15:01 +0200
  Re: Strange location for a comma Laura Creighton <lac@openend.se> - 2015-09-03 15:02 +0200
  Re: Strange location for a comma "Sven R. Kunze" <srkunze@mail.de> - 2015-09-04 01:01 +0200

csiph-web