Re: [Python-ideas] Overloading operators for testing

2016-09-17 Thread Greg Ewing
Arek Bulski wrote: def __glob_eq__(a,b): if not a == b: raise FoundInequalityError(a,b) return True assert obj1 == obj2 #<-- using eq above How would you ensure that this overriding only applied in the places you want it? You don't want to change the meaning of == in the code

Re: [Python-ideas] divmod(): fallback to __floordiv__ and __mod__?

2016-09-17 Thread Chris Angelico
On Sun, Sep 18, 2016 at 8:06 AM, Ethan Furman wrote: > Just like Python will use the defined __ne__ if > it's present, or fall back to negating the result of __eq__ if __ne__ is > not present, I see __divmod__ working the same way: > > - is __mod__ present? use it > - is

[Python-ideas] Overloading operators for testing

2016-09-17 Thread Arek Bulski
I am using declarative testing a lot and I found out why unit tests are so clunky. The reason why assertEquals(a,b) is used is because if we put `assert a==b` then nose can catch the AssertionError but wont find out what was returned or expected. This could be easily overcome if we allow

Re: [Python-ideas] divmod(): fallback to __floordiv__ and __mod__?

2016-09-17 Thread Ethan Furman
On 09/17/2016 03:14 PM, Chris Angelico wrote: On Sun, Sep 18, 2016 at 8:06 AM, Ethan Furman wrote: Just like Python will use the defined __ne__ if it's present, or fall back to negating the result of __eq__ if __ne__ is not present, I see __divmod__ working the same way: - is __mod__

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread Terry Reedy
On 9/17/2016 6:51 AM, João Matos wrote: Hello, I would like to suggest adding a clear command (not function) to Python. It's simple purpose would be to clear the REPL screen, leaving the >>> prompt at the top left of the screen. This is something very basic but also very useful for newbies

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread João Matos
Hello, I searched and found several possible solutions to clear the screen in the CPython REPL, but all are, in my opinion, complex for a newbie. The existence of a clear command would be a simple and obvious, therefore accessible to newbies. Best regards, JM On 17-09-2016 14:34, eryk

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread João Matos
Hello, I know about those IPython commands and I searched and found several possible solutions to clear the screen in the CPython REPL, but all are, in my opinion, complex for a newbie. The existence of a clear command would be simple and obvious, therefore accessible to newbies. Best

Re: [Python-ideas] Suggestion: Clear screen command for the REPL

2016-09-17 Thread eryk sun
On Sat, Sep 17, 2016 at 1:15 PM, Wes Turner wrote: > !cls #windows cmd's built-in cls command doesn't clear just the screen, like a VT100 \x1b[1J. It clears the console's entire scrollback buffer. Unix `clear` may also work like that. With GNOME Terminal in Linux, `clear`

Re: [Python-ideas] divmod(): fallback to __floordiv__ and __mod__?

2016-09-17 Thread David Mertz
It seems like this could be something similar to `functools.total_ordering` and decorate a class. In principle that transformation could go in either direction, but only if the decorator is used. On Sat, Sep 17, 2016 at 3:56 AM, Mark Dickinson wrote: > On Sat, Sep 17, 2016

Re: [Python-ideas] divmod(): fallback to __floordiv__ and __mod__?

2016-09-17 Thread Chris Angelico
On Sun, Sep 18, 2016 at 3:57 AM, David Mertz wrote: > For example, '%' is fairly widely (ab)used for meanings other than modulo. > E.g. string formatting. Probably not that many classes that respond to '%' > to do something non-modulo simultaneously implement `.__divmod__()` ...

Re: [Python-ideas] typing.modifiers

2016-09-17 Thread אלעזר
Thank you all! אלעזר (AKA Elazar) On Sat, Sep 17, 2016 at 4:53 AM Steven D'Aprano wrote: > On Sat, Sep 17, 2016 at 03:39:08AM +1000, Chris Angelico wrote: > > On Fri, Sep 16, 2016 at 11:22 PM, אלעזר wrote: > > > P.S. how do I change the name in my