[Python-ideas] Making colons optional?

Riobard Zhan yaogzhan at gmail.com
Sun Feb 8 08:58:31 CET 2009

On Sun, 8 Feb 2009 03:17:25 -0330
Riobard Zhan <yaogzhan at gmail.com> wrote:

> On 6-Feb-09, at 8:41 PM, Mike Meyer wrote:
>> That this consistency - ignoring trailing separators in list
>> structures - can be misunderstood to be an optional ending separator
>> in the degenerate case of a single statement is a good indication of
>> why consistency isn't a trump property.
> This is a very strange view of consistency to me. How many different
> kinds of list separators do we have? I can only think of semicolons
> and commas. I don't think semicolons are anything like commas. Non-
> trailing semicolons can be omitted, while non-trailing commas cannot,
> even if you put each item of [1,2,3] in separate lines.

Oops, I thought I missed a clause. The last sentence should be "Non- 
trailing semicolons can be omitted [if you put each statement in its  
own line], while non-trailing commas cannot, even if you put each item  
of [1,2,3] in separate lines."

On 8-Feb-09, at 3:34 AM, Mike Meyer wrote:
> You still don't understand the semantics of semicolons.  Non-trailing
> semicolons are required, and can *not* be omitted. Try it and see:
> bhuda$ python
> Python 2.6 (r26:66714, Nov 11 2008, 07:45:20)
> [GCC 4.2.1 20070719  [FreeBSD]] on freebsd7
> Type "help", "copyright", "credits" or "license" for more information.
>>>> a = 1; b = 2
>>>> a = 1 b = 2
>  File "<stdin>", line 1
>    a = 1 b = 2
>          ^
> SyntaxError: invalid syntax
> Only *trailing* semicolons - the one following the last statement in
> the list - can be omitted. Just like lists in list literals, in tuple
> literals (module zero & one element tuples), in dictionary literals,
> and as arguments to certain types of functions functions.

I'm really confused by your words. Here is a list of statements.

a = 1; # non-trailing semicolon of the list of statements
b = 2; # trailing semicolon of the list of statements

Both semicolons can be omitted.

Wait a minute... What do you mean by a "list" of statements? Is this  
one list of length 2, or two lists of length 1?

a = 1
b = 2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090208/4fe0c177/attachment.html>

More information about the Python-ideas mailing list