On 6 April 2014 20:07, Chris Angelico rosuav-at-gmail.com
|python-list@python.org| wrote:
> Here's a simpler form of the proposal, which might cover what you
> need. It's basically a short-hand if/elif tree.
>
> case expression comp_op expression:
> suite
> case [comp_op] expression:
> su
On Mon, Apr 7, 2014 at 6:13 AM, Michael Torrie wrote:
> On 04/06/2014 12:07 PM, Chris Angelico wrote:
>> This has a slight oddity of parsing (in that an expression can
>> normally have a comparison in it); if you really want to use the
>> result of a comparison inside a case block, you'd have to p
On Sun, Apr 6, 2014 at 11:49 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote:
> On 3 April 2014 20:12, Ian Kelly ian.g.kelly-at-gmail.com
> |python-list@python.org| wrote:
>> Use this instead [of continue]:
>
>>
>> switch day case in ("Mon", "Tue", "Wed", "Thu", "Fri"):
>> go_to_work = True
>>
On 04/06/2014 12:07 PM, Chris Angelico wrote:
> This has a slight oddity of parsing (in that an expression can
> normally have a comparison in it); if you really want to use the
> result of a comparison inside a case block, you'd have to parenthesize
> it. But it's easy enough to explain to a human
On Mon, Apr 7, 2014 at 3:49 AM, Marco S. wrote:
> switch day case in briefing_days:
>
> lunch_time = datetime.time(11, 30)
> meeting_time = datetime.time(12, 30)
> case not in briefing_days + festive_days:
>
> lunch_time = datetime.time(12)
> meeting_time = datetime.time(14)
> case
On 3 April 2014 20:12, Ian Kelly ian.g.kelly-at-gmail.com |
python-list@python.org| wrote:
> Use this instead [of continue]:
>
> switch day case in ("Mon", "Tue", "Wed", "Thu", "Fri"):
> go_to_work = True
> day_type = "ferial"
> if day in ("Tue", "Thu"):
> lunch_time = datetime
On Fri, Apr 4, 2014 at 10:44 AM, Marko Rauhamaa wrote:
> Consider:
>
> switch local_sabbath():# bad
> case (1, 2, 3) as sabbath:
> ...
I'm not overly fond of that either. That's why I liked the OP's
choice to put the first case in the switch statement.
> Now Python "fram
Ian Kelly :
> On Apr 4, 2014 3:51 AM, "Marko Rauhamaa" wrote:
>>switch: local_sabbath()
>>case (1, 2, 3) as sabbath:
>>...
>>case 6:
>>...
>>else:
>>...
> [...]
>
> What's wrong with the much more natural "switch local_sabbath():"?
Consider:
switch lo
If one were to add switch into Python, wouldn't it be desirable to
make a pattern matching switch (think the "match" or "case" construct
from Haskell or ML)? Python currently has poor support for union/sum
types in general, not just enumerations. It feels weird to add better
support for enumeration
On Apr 4, 2014 3:51 AM, "Marko Rauhamaa" wrote:
>
> >>> switch day casein ("Monday", "Thursday", "Wednesday", "Tuesday",
> >>> "Friday"):
> >>> gotowork = True
> >>> continue
> >>> casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"):
> >>> daytype = "ferial"
> >>> casein
Instead of disabling fallthrough by default, why not disable it all
together?
>>>
>>> I was tempted but there are cases in which it's useful. An example
No, it is never useful, it never was. It came into being by accident, a
design bug turned into an advertised feature.
>>> switch day
On Thu, 03 Apr 2014 11:23:39 -0700, Ethan Furman wrote:
> On 04/03/2014 09:02 AM, Lucas Malor wrote:
>>
>> In reply to Ian Kelly:
>>>
>>> Instead of disabling fallthrough by default, why not disable it all
>>> together?
>>
>> I was tempted but there are cases in which it's useful. An example
>>
>>
On Thu, 03 Apr 2014 15:11:38 -0400, Terry Reedy wrote:
> On 4/3/2014 12:02 PM, Lucas Malor wrote:
>
>>> A more suitable place to propose this would be the python-ideas
>>> mailing list.
>>
>> You're right. I posted here because this list was linked by PEP 1. But
>> now that I read more there's al
On Fri, Apr 4, 2014 at 2:13 PM, Ethan Furman wrote:
> On 04/03/2014 08:09 PM, Chris Angelico wrote:
>>
>> On Fri, Apr 4, 2014 at 1:04 PM, MRAB wrote:
>>>
>>> I thought [continue] went to the end of the loop, but because it's a
>>> loop, it
>>> just wraps around back to the top...
>>
>>
>> It goes
On 04/03/2014 08:09 PM, Chris Angelico wrote:
On Fri, Apr 4, 2014 at 1:04 PM, MRAB wrote:
I thought [continue] went to the end of the loop, but because it's a loop, it
just wraps around back to the top...
It goes to the bottom of the loop, and then the loop condition may or
may not send it to
On Fri, Apr 4, 2014 at 1:04 PM, MRAB wrote:
> I thought [continue] went to the end of the loop, but because it's a loop, it
> just wraps around back to the top...
It goes to the bottom of the loop, and then the loop condition may or
may not send it to the top of the loop.
ChrisA
--
https://mail
On 04/03/2014 07:04 PM, MRAB wrote:
On 2014-04-03 19:23, Ethan Furman wrote:
On 04/03/2014 09:02 AM, Lucas Malor wrote:
In reply to Ian Kelly:
Instead of disabling fallthrough by default, why not disable it all together?
I was tempted but there are cases in which it's useful. An example
s
On 2014-04-03 19:23, Ethan Furman wrote:
On 04/03/2014 09:02 AM, Lucas Malor wrote:
In reply to Ian Kelly:
Instead of disabling fallthrough by default, why not disable it all together?
I was tempted but there are cases in which it's useful. An example
switch day casein ("Monday", "Thursday
On Fri, Apr 4, 2014 at 10:03 AM, Mark Lawrence wrote:
> Please don't take this personally, but there's more chance of me being the
> first ever World President than of anybody getting a switch/case statement
> past the BDFL.
The language in PEP 3103 (written by Guido) doesn't suggest this to
me.
On 02/04/2014 15:53, Lucas Malor wrote:
Hi all. I would proposeto you all a switch-case syntax for Python. I already
read PEP 3103 and I'm not completely satisfied by any of the proposed
solutions. This is my proposal:
switch_stmt ::= "switch" identifier "case" expression_list ":" suite
On Fri, Apr 4, 2014 at 5:12 AM, Ian Kelly wrote:
> Use this instead:
>
> switch day case in ("Mon", "Tue", "Wed", "Thu", "Fri"):
> go_to_work = True
> day_type = "ferial"
> if day in ("Tue", "Thu"):
> lunch_time = datetime.time(11, 30)
> meeting_time = datetime.time(12,
On 4/3/2014 12:02 PM, Lucas Malor wrote:
A more suitable place to propose this would be the python-ideas mailing list.
You're right. I posted here because this list was linked by PEP 1. But now that
I read more there's also python-ideas listed. Let me know if I have to continue
there instead
On 04/03/2014 09:02 AM, Lucas Malor wrote:
In reply to Ian Kelly:
Instead of disabling fallthrough by default, why not disable it all together?
I was tempted but there are cases in which it's useful. An example
switch day casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"):
On Thu, Apr 3, 2014 at 10:02 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote:
>> __contains__ is not part of the interface for iterables
>
> For what I know there's not an Iterable interface. For example List simply
> extends Object. I hope that an ABC Iterable class will be introduced in a
> futu
Thank you for reading and commenting my proposal. Here are my replies:
In reply to Chris Angelico:
> I don't like the "iterable vs non-iterable" distinction. Compare: [...]
> case "Test": # And there's your problem.
Yes, I had already thought after I posted that testing against string it's a
pr
On Wed, Apr 2, 2014 at 7:06 PM, Steven D'Aprano wrote:
> If we're going to add "switch" and "case" keywords, how about we also add
> "of"? Then we can write:
>
> switch x case of a, b, c:
> # x equals one of a, b or c
> case of d, e, f:
> # x equals one of d, e or f
> case in g, h, i:
>
On Thu, 03 Apr 2014 08:50:47 +1100, Chris Angelico wrote:
> On Thu, Apr 3, 2014 at 1:53 AM, Lucas Malor <3kywjyd...@snkmail.com>
> wrote:
>> For example, in a "switch x" statement, the code "case iterable: " is
>> identical to "if x in iterable: " (or elif etc). So if you want to
>> perform the sa
On Thu, Apr 3, 2014 at 1:53 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote:
> For example, in a "switch x" statement, the code "case iterable: " is
> identical to "if x in iterable: " (or elif etc). So if you want to perform
> the same case block for more than one value, you have only to specify
On Wed, Apr 2, 2014 at 8:53 AM, Lucas Malor <3kywjyd...@snkmail.com> wrote:
> Hi all. I would proposeto you all a switch-case syntax for Python. I already
> read PEP 3103 and I'm not completely satisfied by any of the proposed
> solutions. This is my proposal:
A more suitable place to propose th
Hi all. I would proposeto you all a switch-case syntax for Python. I already
read PEP 3103 and I'm not completely satisfied by any of the proposed
solutions. This is my proposal:
switch_stmt ::= "switch" identifier "case" expression_list ":" suite
("case" expression_list ":" suite)*
["e
30 matches
Mail list logo