Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95927
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: Strange location for a comma |
| Date | 2015-09-03 14:48 +0200 |
| Organization | None |
| References | <55e83afb$0$3157$426a74cc@news.free.fr> <55e83ce3$0$3327$426a74cc@news.free.fr> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.61.1441284505.8327.python-list@python.org> (permalink) |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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