[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-28 Thread Luciano Ramalho
Homonyms are words spelled the same way with different meanings, like bat (flying mammal) and bat (club used to hit a baseball) (btw, club (a blunt instrument) and club (a closed association of people))... In 22 years of programming Python, I always understood the "pass" keyword as "to forgo an op

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-28 Thread Jonathan Goble
On Wed, Oct 28, 2020 at 12:48 PM Emily Bowman wrote: > On Wed, Oct 28, 2020 at 6:49 AM Jean Abou Samra > wrote: > >> where `impossible` raises AssertionError. >> > > Reserving a common English word as a new keyword (whether fail or > impossible) is the mother of all breaking changes. The syntact

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-28 Thread Emily Bowman
On Wed, Oct 28, 2020 at 6:49 AM Jean Abou Samra wrote: > where `impossible` raises AssertionError. > Reserving a common English word as a new keyword (whether fail or impossible) is the mother of all breaking changes. The syntactic sugar it provides is not only tiny, it's pretty much negative, s

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-28 Thread Jean Abou Samra
Hello, In the context of pattern matching, not accepting a match subject that does not match any of the case clauses is probably going to be frequent if not the most frequent. Thus, when PEP 634, 635, 636 are -- hopefully -- accepted, and experience with the feature is gained, this idea might be

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-26 Thread Evpok Padding
`raise NotImplementedError` https://docs.python.org/3/library/exceptions.html#NotImplementedError I think would be the canonical solution. E On Mon, 26 Oct 2020 at 20:34, Victor Stinner wrote: > If you use the unittest module, I suggest you to use self.fail() instead: > it is standard. Moreover

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-26 Thread Victor Stinner
If you use the unittest module, I suggest you to use self.fail() instead: it is standard. Moreover, you can specify a message. https://docs.python.org/dev/library/unittest.html#unittest.TestCase.fail Victor Le ven. 23 oct. 2020 à 21:36, Umair Ashraf a écrit : > Hello > > Can I suggest a feature

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-23 Thread Ethan Furman
On 10/23/20 4:50 PM, Steven D'Aprano wrote: On Fri, Oct 23, 2020 at 01:06:36PM -0700, Ethan Furman wrote: I think having a *fail* keyword for unit testing would be great. Luckily, we already have it: assert False I take it you don't run your unit tests under -O :-) `raise Exception`

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-23 Thread Steven D'Aprano
On Fri, Oct 23, 2020 at 01:06:36PM -0700, Ethan Furman wrote: > >I think having a *fail* keyword for unit testing > >would be great. > > Luckily, we already have it: > > assert False I take it you don't run your unit tests under -O :-) `raise Exception` works fine for me. -- Steve

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-23 Thread Greg Ewing
On 24/10/20 7:52 am, Umair Ashraf wrote: class MyTest(unittest.TestCase):    def test_this_and_that(self):       """       Given inputs       When action is done       Then it should pass       """       fail def fail(): raise Exception("It didn't work!") Not every one-line function

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-23 Thread Ethan Furman
On 10/23/20 11:52 AM, Umair Ashraf wrote: Hello Howdy! Can I suggest a feature to discuss and hopefully develop and send a PR. You can, but the place to do it is Python Ideas: https://mail.python.org/mailman3/lists/python-ideas.python.org/ python-id...@python.org I think having

[Python-Dev] Re: fail keyword like there is pass keyword

2020-10-23 Thread Stanislav Oatmeal
I do not understand how a simple raise is worse than this. A simple variable holding some standard error (like test not implemented error) should be no different. (like fail = NotImplementedError("Test has not been implemented yet") I feel like this is a useless syntactic sugar but if you give s