Command line parsing is a case where switch
>>>>>> statements are often used, e.g. in shell scripts.
>>>>>
>>>>> I've seen at least six different ways of simulating switches, so
>>>>> those
>>>>> people who want them, can h
On 16/03/2016 15:27, Antoon Pardon wrote:
Op 16-03-16 om 15:02 schreef Mark Lawrence:
On 16/03/2016 13:38, Antoon Pardon wrote:
Op 16-03-16 om 12:07 schreef Mark Lawrence:
Raise the item on the python-ideas mailing list for the umpteenth time
then, and see how far you get.
I don't care enou
On 20/03/2016 08:01, Rustom Mody wrote:
On Wednesday, March 16, 2016 at 5:51:21 PM UTC+5:30, Marko Rauhamaa wrote:
BartC :
On 16/03/2016 11:07, Mark Lawrence wrote:
but I still very much doubt we'll be adding a switch statement --
it's a "sexy" language design issue
I did *NOT* write the
and "==" (~ "equal?").
>The "case" form makes use of the operator "eqv?" that is missing from
>Python ("eqv?" compares numbers numerically but is otherwise the same
>as "eq?").
>
>
> Marko
I think it needs to b
Op 16-03-16 om 18:24 schreef Mark Lawrence:
> On 16/03/2016 15:27, Antoon Pardon wrote:
>> Op 16-03-16 om 15:02 schreef Mark Lawrence:
>>> On 16/03/2016 13:38, Antoon Pardon wrote:
Op 16-03-16 om 12:07 schreef Mark Lawrence:
>
> Raise the item on the python-ideas mailing list for the u
On Thursday 17 March 2016 16:45, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>> On Thu, 17 Mar 2016 11:31 am, Chris Angelico wrote:
>>
>>>orig = globals()[cls.__name__]
>>
>> I wouldn't want to rely on it working with decorator syntax either. Even
>> if it does now, I'm not sure that's a l
On Thu, Mar 17, 2016 at 8:23 PM, Antoon Pardon
wrote:
> Op 17-03-16 om 03:02 schreef Chris Angelico:
>> On Thu, Mar 17, 2016 at 12:54 PM, Steven D'Aprano
>> wrote:
>>
>>> I wouldn't want to rely on it working with decorator syntax either. Even if
>>> it does now, I'm not sure that's a language g
On Thu, 17 Mar 2016 12:15 am, l0r0m0a0...@gmail.com wrote:
> What hath I wrought?
Dr Ray Stantz: Fire and brimstone coming down from the skies! Rivers and
seas boiling!
Dr Egon Spengler: Forty years of darkness! Earthquakes, volcanoes...
Winston Zeddemore: The dead rising from the grave!
Dr P
What hath I wrought?
--
https://mail.python.org/mailman/listinfo/python-list
uot;==" (~ "equal?").
The "case" form makes use of the operator "eqv?" that is missing from
Python ("eqv?" compares numbers numerically but is otherwise the same
as "eq?").
Yes, a few scripting languages can do interesting things with swit
l0r0m0a0...@gmail.com:
> Gratified to see that with all this back-and-forth this thread still
> has a sense of humor. Perhaps, we can all just agree to disagree? :)
I might agree with you if you tell me what we disagree about.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, 16 Mar 2016 09:34 pm, BartC wrote:
> (BTW why does Python have 'elif' when if-else is all that is really
> needed?)
To save indentation.
if condition:
block
else:
if other:
block
else:
if third:
block
else:
block
versus:
if
On 16/03/2016 19:41, BartC wrote:
On 16/03/2016 09:51, Mark Lawrence wrote:
On 16/03/2016 09:35, Antoon Pardon wrote:
So I guess those who would like a case statement in Python can
only hope a core developer gets bitten by a nasty bug while using
one of those ways of simulating switches.
S
On Thu, 17 Mar 2016 10:14 am, Chris Angelico wrote:
> On Thu, Mar 17, 2016 at 5:31 AM, Antoon Pardon
> wrote:
>> It can be yes. Look at decorators. They don't provide functionality
>> we wouldn't have without them.
>
> Really? Okay, try implementing this without decorators:
[...]
> @monkeypatc
On Thu, Mar 17, 2016 at 11:19 AM, Steven D'Aprano wrote:
> On Thu, 17 Mar 2016 10:14 am, Chris Angelico wrote:
>
>> On Thu, Mar 17, 2016 at 5:31 AM, Antoon Pardon
>> wrote:
>>> It can be yes. Look at decorators. They don't provide functionality
>>> we wouldn't have without them.
>>
>> Really? Oka
BartC :
> On 16/03/2016 11:07, Mark Lawrence wrote:
>> but I still very much doubt we'll be adding a switch statement --
>> it's a "sexy" language design issue
>
> That's the first time I've heard a language feature common in C
> described as sexy.
Scheme has a "switch" statement (a "case" form).
On 16/03/2016 21:43, Mark Lawrence wrote:
On 16/03/2016 19:41, BartC wrote:
That article appears to try to do without using a new switch byte-code,
as the author doesn't see the point. My code to implement a 'switch'
byte-code (for integer expression and constant integer case-expressions)
is b
Gratified to see that with all this back-and-forth this thread still has a
sense of humor. Perhaps, we can all just agree to disagree? :)
--
https://mail.python.org/mailman/listinfo/python-list
Chris Angelico wrote:
So maybe it's a language guarantee that
hasn't been written down somewhere,
The Language Reference says:
[the decorator] is invoked with the function object as the only argument.
The returned value is bound to the function name instead of the function
object.
The "
Op 17-03-16 om 03:02 schreef Chris Angelico:
> On Thu, Mar 17, 2016 at 12:54 PM, Steven D'Aprano wrote:
>
>> I wouldn't want to rely on it working with decorator syntax either. Even if
>> it does now, I'm not sure that's a language guarantee.
> That's the thing, though. It's not a guarantee, yet i
On 16/03/2016 13:38, Antoon Pardon wrote:
Op 16-03-16 om 12:07 schreef Mark Lawrence:
Raise the item on the python-ideas mailing list for the umpteenth time
then, and see how far you get.
I don't care enough. I do care about people using valid arguments.
Arguments have been made for and ag
Op 16-03-16 om 15:02 schreef Mark Lawrence:
> On 16/03/2016 13:38, Antoon Pardon wrote:
>> Op 16-03-16 om 12:07 schreef Mark Lawrence:
>>>
>>> Raise the item on the python-ideas mailing list for the umpteenth time
>>> then, and see how far you get.
>>
>> I don't care enough. I do care about people
Steven D'Aprano wrote:
On Thu, 17 Mar 2016 11:31 am, Chris Angelico wrote:
orig = globals()[cls.__name__]
I wouldn't want to rely on it working with decorator syntax either. Even if
it does now, I'm not sure that's a language guarantee.
The following idiom relies on similar behaviour:
On 16/03/2016 13:27, Steven D'Aprano wrote:
On Thu, 17 Mar 2016 12:15 am, l0r0m0a0...@gmail.com wrote:
What hath I wrought?
Dr Ray Stantz: Fire and brimstone coming down from the skies! Rivers and
seas boiling!
Dr Egon Spengler: Forty years of darkness! Earthquakes, volcanoes...
Winston Ze
Antoon Pardon :
> Op 16-03-16 om 20:27 schreef Marko Rauhamaa:
>> Antoon Pardon :
>>> Look at decorators. They don't provide functionality we wouldn't have
>>> without them. So we don't actually need them. Do you argue that
>>> introducing them wasn't progress?
>> I do.
>
> Way to miss the point.
On Thu, 17 Mar 2016 11:31 am, Chris Angelico wrote:
> Yes... in theory. But try rewriting my example to avoid decorator
> syntax. It won't work, because of this line:
>
> orig = globals()[cls.__name__]
That's a nasty, dirty piece of code, and I hope you are thoroughly ashamed
of having writt
Op 17-03-16 om 01:31 schreef Chris Angelico:
> On Thu, Mar 17, 2016 at 11:19 AM, Steven D'Aprano wrote:
>> On Thu, 17 Mar 2016 10:14 am, Chris Angelico wrote:
>>
>>> On Thu, Mar 17, 2016 at 5:31 AM, Antoon Pardon
>>> wrote:
It can be yes. Look at decorators. They don't provide functionality
On 16/03/2016 11:07, Mark Lawrence wrote:
I don't want to discourage you too much, but I think that adding a
switch statement comes *very* low on the list of improvements we would
like to make in Python 3.5.
We should probably focus on speed ...
OK, you're coming round...
but I still very m
On Thu, Mar 17, 2016 at 5:31 AM, Antoon Pardon
wrote:
> It can be yes. Look at decorators. They don't provide functionality
> we wouldn't have without them.
Really? Okay, try implementing this without decorators:
def monkeypatch(cls):
orig = globals()[cls.__name__]
print("Monkeypatch",id
BartC :
> On 16/03/2016 14:31, Marko Rauhamaa wrote:
>> Scheme has this:
>
>> (case (die10)
>> ((1 3 5 7 9)
>>=> (lambda (n)
>> n))
>> (else
>>=> (lambda (n)
>> (/ n 2
>>
>> which maps 1, 3, 5, 7 and 9 onto themselves but halves 2, 4, 6,
Op 16-03-16 om 20:27 schreef Marko Rauhamaa:
> Antoon Pardon :
>
>> Look at decorators. They don't provide functionality we wouldn't have
>> without them. So we don't actually need them. Do you argue that
>> introducing them wasn't progress?
> I do.
Way to miss the point. Sure there will be people
On 16/03/2016 09:51, Mark Lawrence wrote:
On 16/03/2016 09:35, Antoon Pardon wrote:
So I guess those who would like a case statement in Python can
only hope a core developer gets bitten by a nasty bug while using
one of those ways of simulating switches.
So that core developers can waste th
On Thu, 17 Mar 2016 05:48 pm, Chris Angelico wrote:
> On Thu, Mar 17, 2016 at 5:29 PM, Steven D'Aprano
> wrote:
>> I don't think that property is a similar situation. I think what happens
>> here is that the first call to property sets:
>>
>> # @property def x...
>> x = property(x)
>>
>> Then the
On 16/03/2016 13:15, l0r0m0a0...@gmail.com wrote:
What hath I wrought?
The Comfy Chair :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, Mar 17, 2016 at 12:54 PM, Steven D'Aprano wrote:
> On Thu, 17 Mar 2016 11:31 am, Chris Angelico wrote:
>
>> Yes... in theory. But try rewriting my example to avoid decorator
>> syntax. It won't work, because of this line:
>>
>> orig = globals()[cls.__name__]
>
> That's a nasty, dirty p
On Thu, Mar 17, 2016 at 4:45 PM, Gregory Ewing
wrote:
> Steven D'Aprano wrote:
>>
>> On Thu, 17 Mar 2016 11:31 am, Chris Angelico wrote:
>>
>>>orig = globals()[cls.__name__]
>>
>>
>> I wouldn't want to rely on it working with decorator syntax either. Even
>> if
>> it does now, I'm not sure tha
BartC :
> Yes, a few scripting languages can do interesting things with switch or
> case statements. Perl for example (where I think it is created out other
> language features, but it looks a regular part of the syntax).
>
> Even Ruby has one. It doesn't do anything 's
On Thu, Mar 17, 2016 at 5:29 PM, Steven D'Aprano
wrote:
> I don't think that property is a similar situation. I think what happens
> here is that the first call to property sets:
>
> # @property def x...
> x = property(x)
>
> Then the second decorator does:
>
> # @x.setter def x...
> x = x.setter(
Antoon Pardon :
> Look at decorators. They don't provide functionality we wouldn't have
> without them. So we don't actually need them. Do you argue that
> introducing them wasn't progress?
I do.
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Op 17-03-16 om 09:57 schreef Marko Rauhamaa:
> Antoon Pardon :
>
>> Op 16-03-16 om 20:27 schreef Marko Rauhamaa:
>>> Antoon Pardon :
Look at decorators. They don't provide functionality we wouldn't have
without them. So we don't actually need them. Do you argue that
introducing them
On 16/03/2016 14:31, Marko Rauhamaa wrote:
BartC :
Even Ruby has one.
case
when this
when that
That's a different topic.
Yes but, if Ruby has it, why shouldn't Python? (Aren't they rivals or
something?)
which is exactly equivalent to if this... elif that... (when th
Op 17-03-16 om 00:14 schreef Chris Angelico:
> def monkeypatch(cls):
> orig = globals()[cls.__name__]
> print("Monkeypatch",id(cls),"into",id(orig))
> for attr in dir(cls):
> if not attr.startswith("_"):
> setattr(orig,attr,getattr(cls,attr))
> return orig
>
> cl
On Thu, Mar 17, 2016 at 9:53 PM, Steven D'Aprano wrote:
> On Thu, 17 Mar 2016 05:48 pm, Chris Angelico wrote:
>
>> Okay. Let's try this.
> [...]
>> Decorators work. Now let's try NOT using decorators.
>
> You are still using a decorator. You're just not using @ decorator syntax.
Oops, sorry. That
On 16/03/2016 11:16, BartC wrote:
On 16/03/2016 11:07, Mark Lawrence wrote:
I don't want to discourage you too much, but I think that adding a
switch statement comes *very* low on the list of improvements we would
like to make in Python 3.5.
We should probably focus on speed ...
OK, you're c
ython programmer.
I have no interest what other languages use switch/case statements
for, as we've on the PYTHON mailing list.
There once were multiple ways to simulate a conditional expression.
And it was generally thought that using if else statements instead
of a conditional expression was u
those
>>> people who want them, can have them. if-elif chains are not likely to
>>> kill any Python programmer.
>>>
>>> I have no interest what other languages use switch/case statements
>>> for, as we've on the PYTHON mailing list.
>>
>> There
% of other
languages, but is generally considered more flexible and readable than the if-elif, was
missing in Python. (your link "Switch Statement Code Smell" not withstanding)
Have a great day :)
Switch and case statements are such a waste of time that, in order to
understand them
statements are often used, e.g. in shell scripts.
I've seen at least six different ways of simulating switches, so those
people who want them, can have them. if-elif chains are not likely to
kill any Python programmer.
I have no interest what other languages use switch/case statements
for, as
tatements are often used, e.g. in shell scripts.
>
> I've seen at least six different ways of simulating switches, so those
> people who want them, can have them. if-elif chains are not likely to
> kill any Python programmer.
>
> I have no interest what other languages
Christian Gollwitzer :
> That happens indeed if one were to simulate polymorphism using switch
> statements, but not for other cases.
There are not many other cases. Decoding is the only generally valid
case I can think of.
> In Python, you need to go the other way round, you don't have a
> swit
are the way to go. Command line parsing is a case where switch
statements are often used, e.g. in shell scripts.
I've seen at least six different ways of simulating switches, so those
people who want them, can have them. if-elif chains are not likely to
kill any Python programmer.
I have
Am 16.03.16 um 05:26 schrieb Mark Lawrence:
So you would rather write something like:-
switch (x):
case COW:
moo()
break
case DUCK:
quack()
break
default IDUNNO:
panic()
than:-
x.makeNoise()
No sane person would do that. But just because you selected the w
On 16/03/2016 01:55, jj0gen0i...@gmail.com wrote:
You have apparently mistaken me for someone who's worried. I don't use Python, I was
just curious as to why a construct that is found, not only to be useful in 95% of other
languages, but is generally considered more flexible and readable than
enerally considered more
> flexible and readable than the if-elif, was missing in Python. (your link
> "Switch Statement Code Smell" not withstanding)
>
> Have a great day :)
Switch and case statements are such a waste of time that, in order to
understand them you have to men
You have apparently mistaken me for someone who's worried. I don't use Python,
I was just curious as to why a construct that is found, not only to be useful
in 95% of other languages, but is generally considered more flexible and
readable than the if-elif, was missing in Python. (your link "Sw
On 16/03/2016 00:51, BartC wrote:
On 15/03/2016 23:47, jj0gen0i...@gmail.com wrote:
Thanks for the informative post. I've read it and disagree with the
rational, it places Python in a decided minority of the major languages.
And this proposal (3103) was by the guy who invented the language!
On 15/03/2016 23:47, jj0gen0i...@gmail.com wrote:
Thanks for the informative post. I've read it and disagree with the rational,
it places Python in a decided minority of the major languages.
And this proposal (3103) was by the guy who invented the language!
Good thing he didn't have design-
On 15/03/2016 23:47, jj0gen0i...@gmail.com wrote:
Thanks for the informative post. I've read it and disagree with the rational,
it places Python in a decided minority of the major languages.
https://en.wikipedia.org/wiki/Conditional_(computer_programming)#Case_and_switch_statements
See secti
Thanks for the informative post. I've read it and disagree with the rational,
it places Python in a decided minority of the major languages.
https://en.wikipedia.org/wiki/Conditional_(computer_programming)#Case_and_switch_statements
See section "Choice system cross reference"
Thanks again for
On 15/03/2016 20:46, jj0gen0i...@gmail.com wrote:
Given that "Case Statements" are more compact and less redundant than a
sequence of if-elif statements, and usually can contain embedded match lists:
Is there any chance future versions of Python will adopt a case structure?
Some
Given that "Case Statements" are more compact and less redundant than a
sequence of if-elif statements, and usually can contain embedded match lists:
Is there any chance future versions of Python will adopt a case structure?
Something like
select x
case in [1,2,3,5,7,9]
print ..
61 matches
Mail list logo