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

2016-09-17 Thread Spencer Brown
Currently, calling divmod() on a class with __floordiv__ and __mod__ defined, but not __divmod__ raises a TypeError. Is there any reason why it doesn't fallback to (self // x, self % x)? The invariants described in the function documentation should still apply (with well behaved % and //). If di

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

2016-09-17 Thread João Matos
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 learning Python from the REPL. After some

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

2016-09-17 Thread Mark Dickinson
On Sat, Sep 17, 2016 at 10:01 AM, Spencer Brown wrote: > Currently, calling divmod() on a class with __floordiv__ and __mod__ > defined, but not __divmod__ raises a TypeError. Is there any reason why it > doesn't fallback to (self // x, self % x)? It's an interesting idea. I wonder whether the fa

[Python-ideas] (Windows-only - calling Steve Dower) Consider adding a symlink to pip in the same location as the py launcher

2016-09-17 Thread João Matos
Hello, If Py3.5 is installed in user mode instead of admin (all users) and we follow your advice that we shouldn't add it to the PATH env var, we can execute Python using the py launcher, but we can't use pip. Please consider adding a pip symlink in the same location as the py launcher. Best

[Python-ideas] (Windows-only - calling Steve Dower) Is Python for Windows using PGO? If not consider this a suggestion.

2016-09-17 Thread João Matos
Hello, Is Python for Windows using PGO (Profile Guided Optimizations)? If not consider this a suggestion. Best regards, JM ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct:

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

2016-09-17 Thread Chris Angelico
On Sat, Sep 17, 2016 at 8:51 PM, João Matos wrote: > 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 n

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

2016-09-17 Thread Oleg Broytman
Hi! On Sat, Sep 17, 2016 at 11:51:16AM +0100, Jo??o Matos wrote: > Hello, > > I would like to suggest adding a clear command (not function) to Python. Pressing [Ctrl]+[L] works for me. > Best regards, > JM Oleg. -- Oleg Broytmanhttp://phdru.name/[email protected]

Re: [Python-ideas] (Windows-only - calling Steve Dower) Consider adding a symlink to pip in the same location as the py launcher

2016-09-17 Thread Paul Moore
On 17 September 2016 at 11:55, João Matos wrote: > If Py3.5 is installed in user mode instead of admin (all users) and we > follow your advice that we shouldn't add it to the PATH env var, we can > execute Python using the py launcher, but we can't use pip. > Please consider adding a pip symlink i

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

2016-09-17 Thread João Matos
Hello, Doesn't work on Windows. Best regards, JM On 17-09-2016 12:07, Oleg Broytman wrote: Hi! On Sat, Sep 17, 2016 at 11:51:16AM +0100, Jo??o Matos wrote: Hello, I would like to suggest adding a clear command (not function) to Python. Pressing [Ctrl]+[L] works for me. Best rega

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

2016-09-17 Thread João Matos
Hello, In other interpreted programming languages the clear screen command (whatever it is) also does not clear the session. It just clears the screen clutter. As I said, this would be very useful for newbies, which don't know anything about usercustomize or sitecustomize. Best regards, J

Re: [Python-ideas] (Windows-only - calling Steve Dower) Consider adding a symlink to pip in the same location as the py launcher

2016-09-17 Thread João Matos
Hello, OK, I didn't know that option. Thanks. May I suggest adding a notice to the Windows Python Installer alerting to use py instead of python and py -m pip instead of pip (only if the user doesn't choose the option to add it to the path, of course)? On the other hand, maybe instead of a p

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

2016-09-17 Thread Wes Turner
With IPython, there are a number of ways to reset the terminal display: clear # %clear !cls #windows !reset - http://stackoverflow.com/questions/6892191/clearing-the-screen-in-ipython - Ctrl-L is a readline binding - http://pythonhosted.org/pyreadline/usage.html#pyreadline-with-python-

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

2016-09-17 Thread eryk sun
On Sat, Sep 17, 2016 at 11:11 AM, João Matos wrote: >On 17-09-2016 12:07, Oleg Broytman wrote: >> >> Pressing [Ctrl]+[L] works for me. > > Doesn't work on Windows. Windows 10 added VT100 support to the console, so you can create a little cls() function to clear the screen: cls = lambda:

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 regar

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 sun

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` leaves a single screen

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 quotes? I believe אלעזר is not > very easy > >

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 at 10:01 AM, Spencer

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

2016-09-17 Thread Ethan Furman
On 09/17/2016 10:34 AM, David Mertz wrote: On Sat, Sep 17, 2016 at 3:56 AM, Mark Dickinson wrote: On Sat, Sep 17, 2016 at 10:01 AM, Spencer Brown wrote: Currently, calling divmod() on a class with __floordiv__ and __mod__ defined, but not __divmod__ raises a TypeError. Is there any reason why

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

2016-09-17 Thread David Mertz
The fallback you described would be a change in the behavior of some working programs. Moreover, it would only affect custom classes where adding a decorator is an option (even in external code, you can use `MyThing = total_divmod(library.MyThing)` under this option. Showing that a recipe for a d

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__()` ... but > maybe some

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 lear

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

2016-09-17 Thread Ethan Furman
On 09/17/2016 10:57 AM, David Mertz wrote: The fallback you described would be a change in the behavior of some working programs. Moreover, it would only affect custom classes where adding a decorator is an option (even in external code, you can use `MyThing = total_divmod(library.MyThing)` u

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 __floordiv__ present? use

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__ present?

[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 oveloading

Re: [Python-ideas] Overloading operators for testing

2016-09-17 Thread Ryan Gonzalez
FYI, pytest already does this: http://doc.pytest.org/en/latest/ -- Ryan [ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong. http://kirbyfan64.github.io/ On Sep 17, 2016 7:55 PM, "Arek Bulski" wrote: > I am using declarative testing a lot and I found

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 under