[Python-ideas] Add "default" kwarg to list.pop()
Steven D'Aprano
steve at pearwood.info
Tue Nov 6 18:16:21 EST 2018
On Tue, Nov 06, 2018 at 01:03:54PM -0600, Abe Dillon wrote:
> I don't understand the rationale behind PEP 463's rejection. Guido says, "I
> disagree with the position that EAFP is better than LBYL, or "generally
> recommended" by Python. (Where do you get that?...";
I can't comment on Guido's question about "generally recommended", but
as for the first part, I agree: neither EAFP nor LBYL is "better", they
are both appropriate under different circumstances. Sometimes one is
clearer and more efficient than the other. The only time I would say
that EAFP is clearly better is when LBYL introduces "Time Of Check To
Time Of Use" bugs.
> Which brings me to the question: What happens when a PEP gets rejected? Is
> it final? Is there a process for reviving a PEP?
Nothing is final-final. You can try opening a competing PEP, or take
over as champion of the existing PEP (assuming Chris is willing to step
aside). You ought to respond to the reasons given in the rejection.
It's probably a good idea to gauge the chances of success by asking on
Python-Ideas and Python-Dev first, to avoid the core devs saying "Oh
give it up, it's not going to happen!" after you've wasted time trying
to revise a rejected PEP.
[...]
> I think the colon (and maybe
> 'except' keyword) could be replaced with an exclamation point:
>
> value = lst[2] except IndexError! "No value"
[...]
> if that appeases the people who dislike the over-use of colons.
And I think that this is precisely the sort of syntax that prompted
Guido to write many years ago that language design is not merely a
problem-solving exercise. Aesthetics are important. This is not just a
matter of finding an unused character or two and hammering it into the
the language. That's how you get Perl, which is not a pretty language.
> A full exception list would have to be in parentheses which get's ugly, but
> would also be (I would wager) a less common form:
>
> dirlist.append(os.getcwd() (AttributeError, OSError as e)! os.curdir)
>
> That might need some work. I don't know if it's compatible w/ the compiler.
> It may have to start with "try" or something, but it seems pretty close to
> a workable solution.
Seeing that syntax, the phrase that came to my mind was not so much
"close to workable" and more "kill it with fire!".
--
Steve
More information about the Python-ideas
mailing list