Re: [Python-ideas] Make partial a built-in

2016-09-19 Thread Stefan Behnel
אלעזר schrieb am 19.09.2016 um 17:59: > If at all, it should be function.bind(). It was discussed and dropped; I > don't remember why, but one problem is that it looks like an in-place > modification. IMHO, the main drawback of that solution is that it only works for functions and not for any othe

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 06:45 PM, Chris Angelico wrote: Yes we are (at least in that instance). With more real-world tests, they're allowed to use all the standard library - this was the "in some cases" bit. (We don't teach float multiplication, because it's very complication, but we do teach some stuff a

[Python-ideas] singledispatch for instance methods

2016-09-19 Thread Tim Mitchell
Hi All, We have a modified version of singledispatch at work which works for methods as well as functions. We have open-sourced it as methoddispatch (pypi: https://pypi.python.org/pypi/methoddispatch). IMHO I thought it would make a nice addition to python stdlib. What does everyone else think?

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

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 01:35:53PM -0700, João Matos wrote: > Hello, > > I don't see why creating a clear command would interfere with dict.clear() > which is a function/method. For the same reason that you can't have a method called foo.while or foo.if or foo.raise. If clear is a "command" (a

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 05:06:50PM -0700, Ethan Furman wrote: > On 09/19/2016 04:38 PM, אלעזר wrote: > > >I was talking specifically about advanced courses, in which an assignment > > is "implement a side-channel attack using data" and you can use whatever > > library you like. > > Am I misunders

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 10:42 AM, Steven D'Aprano wrote: > On Tue, Sep 20, 2016 at 09:34:12AM +1000, Chris Angelico wrote: > >> It's more than that, though. When a student is given an assignment, >> it's usually to help said student to learn to *write code*, not to >> learn how to walk into the pl

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 11:35:39PM +, אלעזר wrote: > Xavier, how is connecting and installing different from a windows popup > "this software requires changes to your firewall settings" or "requires > elevated privileges" which already happens. I am all for a two-step > process, but I think it

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 04:55:26PM +, אלעזר wrote: > A library in PyPi still requires installing it, which undermine many of > the benefits. It won't help me with my gist/activestate recipe, code that I > send to a friend, etc. I want to lower the barrier of inexperienced users. When you say

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Tue, Sep 20, 2016 at 09:34:12AM +1000, Chris Angelico wrote: > It's more than that, though. When a student is given an assignment, > it's usually to help said student to learn to *write code*, not to > learn how to walk into the plumbing store of PyPI and look for > something that approximates

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 08:34:41PM +, אלעזר wrote: > If we have this syntax for Python3.6 3.6 now is under feature-freeze. The earliest any new features can be added is 3.7. -- Steve ___ Python-ideas mailing list Python-ideas@python.org https:/

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 3:06 AM Ethan Furman wrote: > On 09/19/2016 04:38 PM, אלעזר wrote: > > > I was talking specifically about advanced courses, in which an assignment > > is "implement a side-channel attack using data" and you can use whatever > > library you like. > > Am I misunderstanding

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 04:38 PM, אלעזר wrote: I was talking specifically about advanced courses, in which an assignment is "implement a side-channel attack using data" and you can use whatever library you like. Am I misunderstanding, or did you just say you want this new functionality in order to im

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
But grepping and piping could work I assume? On Tue, Sep 20, 2016 at 2:41 AM Chris Angelico wrote: > On Tue, Sep 20, 2016 at 9:27 AM, Xavier Combelle > wrote: > > I find the idea of tracking the dependencies in the script might be a > > good idea. > > However, magically downloading without warn

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 9:27 AM, Xavier Combelle wrote: > I find the idea of tracking the dependencies in the script might be a > good idea. > However, magically downloading without warning the user is in my point > of view for sure a bad idea. > I would far prefer that pip could scan a script to

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 2:34 AM Chris Angelico wrote: > On Tue, Sep 20, 2016 at 9:20 AM, Stephen J. Turnbull > wrote: > > אלעזר writes: > > > > > Another use case, though I admit not the top priority of anyone here, > is > > > that of assignment checkers. In most courses I took at the > univer

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Xavier, how is connecting and installing different from a windows popup "this software requires changes to your firewall settings" or "requires elevated privileges" which already happens. I am all for a two-step process, but I think it should be more user friendly, and it can be done as a Python co

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 9:20 AM, Stephen J. Turnbull wrote: > אלעזר writes: > > > Another use case, though I admit not the top priority of anyone here, is > > that of assignment checkers. In most courses I took at the university, the > > person who checks the assignments says something like "yo

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 2:20 AM Stephen J. Turnbull < turnbull.stephen...@u.tsukuba.ac.jp> wrote: > אלעזר writes: > > > Another use case, though I admit not the top priority of anyone here, is > > that of assignment checkers. In most courses I took at the university, > the > > person who checks

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Xavier Combelle
Le 19/09/2016 à 18:25, אלעזר a écrit : > Many proposals to add something to stdlib are rejected here with the > suggestion to add such library to pypi first. As noted by someone, > pypi is not as reachable as stdlib, and one should install that > package first, which many people don't know how. Ad

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Stephen J. Turnbull
אלעזר writes: > Another use case, though I admit not the top priority of anyone here, is > that of assignment checkers. In most courses I took at the university, the > person who checks the assignments says something like "you are allowed to > use only this this and this libraries", in order n

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Sounds good, thanks. So I'll suggest adding the method mentioned in Paul's code as a promised API, either as pip.install or otherwise. `pip.main(['install', 'boltons'])` is not the clearest it can get. Elazar On Tue, Sep 20, 2016 at 2:02 AM David Mertz wrote: > >>> import pip > >>> pip.main(['

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread David Mertz
>>> import pip >>> pip.main(['install', 'boltons']) Requirement already satisfied (use --upgrade to upgrade): boltons in ./anaconda/lib/python3.5/site-packages 0 This is easy, short, and uses existing syntax and an existing module. Yes, I know technically the API isn't promised; I wouldn't object

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
On Tue, Sep 20, 2016 at 1:40 AM Paul Moore wrote: > On 19 September 2016 at 23:13, אלעזר wrote: > > Alternative syntax might be that of import decorators > > > > @from_pip("attrs") > > import attr > > At which point you may as well just (insert disclaimer about "using > pip's internal API isn't

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 23:13, אלעזר wrote: > Alternative syntax might be that of import decorators > > @from_pip("attrs") > import attr At which point you may as well just (insert disclaimer about "using pip's internal API isn't supported" here, and glossing over the fact that pip doesn't yet ha

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Alternative syntax might be that of import decorators @from_pip("attrs") import attr It's only worthwhile if there are any other uses for import decorators. One possibility is for other online modules, probably by giving a url. I can come up with more, but it's making a solution without having a

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Another use case, though I admit not the top priority of anyone here, is that of assignment checkers. In most courses I took at the university, the person who checks the assignments says something like "you are allowed to use only this this and this libraries", in order not to mess with unknown dep

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

2016-09-19 Thread Paul Moore
On 19 September 2016 at 21:35, João Matos wrote: > Hello, > > I don't see why creating a clear command would interfere with dict.clear() > which is a function/method. > > Although my first idea was a clear command, I have no problem if it is a > clear() function from site.py. > > I didn't suggest

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 21:34, אלעזר wrote: > Paul, I understand what you say, except the part of compatibility with > Python3.5. Of course such a change is targeting future version more than the > current and previous versions. If we have this syntax for Python3.6, users > of Python3.9 will find

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

2016-09-19 Thread João Matos
Hello, I don't see why creating a clear command would interfere with dict.clear() which is a function/method. Although my first idea was a clear command, I have no problem if it is a clear() function from site.py. I didn't suggest cls because it is normally used to mean class. I use Windows a

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Paul, I understand what you say, except the part of compatibility with Python3.5. Of course such a change is targeting future version more than the current and previous versions. If we have this syntax for Python3.6, users of Python3.9 will find many copy-pastable answers written this way, and othe

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread MRAB
On 2016-09-19 19:48, Chris Angelico wrote: On Tue, Sep 20, 2016 at 4:43 AM, MRAB wrote: On 2016-09-19 18:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) [snip] One possible problem I can see is that if it's quoted you might think th

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 19:52, אלעזר wrote: > Of course it doesn't address the issues - for example, running a python > script from the file manager will result in a failed execution, unexplained. What you're talking about here is deployment of Python "applications" (where in your case, you're f

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:52 AM, אלעזר wrote: > Wow chris, that's a nice one! > > Of course it doesn't address the issues - for example, running a python > script from the file manager will result in a failed execution, unexplained. True, it doesn't; but if anything else goes wrong, you have the

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Wow chris, that's a nice one! Of course it doesn't address the issues - for example, running a python script from the file manager will result in a failed execution, unexplained. On Mon, Sep 19, 2016 at 9:48 PM Chris Angelico wrote: > On Tue, Sep 20, 2016 at 4:43 AM, MRAB wrote: > > On 2016-0

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Then you'll get SyntaxError: from __pip__ imports must occur at the beginning of the file Or "must be string literal or an identifier" if it's allowed outside the beginning of the file. On Mon, Sep 19, 2016 at 9:44 PM MRAB wrote: > On 2016-09-19 18:20, אלעזר wrote: > > Obviously > > > >

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Chris Angelico
On Tue, Sep 20, 2016 at 4:43 AM, MRAB wrote: > On 2016-09-19 18:20, אלעזר wrote: >> >> Obviously >> >> from __pip__ import "run-lambda>=0.1.0" >> >> Which is ugly but not my fault :) >> > [snip] > One possible problem I can see is that if it's quoted you might think that > it's an expression a

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread MRAB
On 2016-09-19 18:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) [snip] One possible problem I can see is that if it's quoted you might think that it's an expression and that you could also write: package = "run-lambda>=0.1.0"

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Ryan I assume any error could be translated to your version through the `from ` statement too? Regarding the rabbit hole, the internet connection and privileges were required for running this script in the first place. I only suggest giving the developer - perhaps not a software engineer at all -

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ryan Gonzalez
This sounds like a great idea, but I've seen stuff like this done before, and it never ends well. You end up with a gargantuan-sized rabbit hole, since running a basic script could now involve using an internet connection and potentially root permissions. IF one were to go this route, I prefer bun

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Sven R. Kunze
Which is still not allowed syntax IIRC? ;) On 19.09.2016 19:20, אלעזר wrote: Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) On Mon, Sep 19, 2016 at 8:16 PM Sven R. Kunze > wrote: I can definitely understand your point.

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 17:59, Joonas Liik wrote: > using pip from within python is not that difficult already. > as can be seen with a glance to: > http://stackoverflow.com/questions/12332975/installing-python-module-within-code Note that pip does not officially support any use of its internal A

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Paul Moore
On 19 September 2016 at 18:20, אלעזר wrote: > Obviously > > from __pip__ import "run-lambda>=0.1.0" If we were going to go down this route (which I'm not at all convinced we should) it should be "from __pypi__ import" not "from __pip__ import" (as PyPI is where the code is coming from, not pi

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Obviously from __pip__ import "run-lambda>=0.1.0" Which is ugly but not my fault :) On Mon, Sep 19, 2016 at 8:16 PM Sven R. Kunze wrote: > I can definitely understand your point. > > The only issue with it (besides that it doesn't seem to be a good way for > dependency management) is how d

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Sven R. Kunze
I can definitely understand your point. The only issue with it (besides that it doesn't seem to be a good way for dependency management) is how do you manage the syntax involved here? Pip provides distributions. Each distribution contains a set of packages and modules. The latter can be impor

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Thanks Joonas. I withdraw my proposal - nothing more is strictly needed. It should be idiomatic somehow, but I don't have any specific suggestion. On Mon, Sep 19, 2016 at 7:59 PM Joonas Liik wrote: > On 19 September 2016 at 19:55, אלעזר wrote: > > A library in PyPi still requires installing it

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Joonas Liik
On 19 September 2016 at 19:55, אלעזר wrote: > A library in PyPi still requires installing it, which undermine many of the > benefits. It won't help me with my gist/activestate recipe, code that I send > to a friend, etc. I want to lower the barrier of inexperienced users. > > As a documentation o

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
A library in PyPi still requires installing it, which undermine many of the benefits. It won't help me with my gist/activestate recipe, code that I send to a friend, etc. I want to lower the barrier of inexperienced users. As a documentation of dependencies it will suffice indeed. Elazar On Mon

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ethan Furman
On 09/19/2016 09:25 AM, אלעזר wrote: Many proposals to add something to stdlib are rejected here with the suggestion to add such library to pypi first. As noted by someone, pypi is not as reachable as stdlib, and one should install that package first, which many people don't know how. Additio

[Python-ideas] from __pip__ import

2016-09-19 Thread אלעזר
Many proposals to add something to stdlib are rejected here with the suggestion to add such library to pypi first. As noted by someone, pypi is not as reachable as stdlib, and one should install that package first, which many people don't know how. Additionally, there is no natural distinction betw

Re: [Python-ideas] Make partial a built-in

2016-09-19 Thread אלעזר
If at all, it should be function.bind(). It was discussed and dropped; I don't remember why, but one problem is that it looks like an in-place modification. Personally I think that higher order programming should not be encouraged (as opposed to functional programming), and from the lambda syntax

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

2016-09-19 Thread eryk sun
On Mon, Sep 19, 2016 at 3:07 PM, Oleg Broytman wrote: >[Ctrl+D] also recognized as EOF only at the start of an input. You're right. I was mixing it up with sys.stdin.buffer.raw.read(), for which Ctrl+D can end the read anywhere if entered twice. Having to enter it twice may be a bug, because

[Python-ideas] Make partial a built-in

2016-09-19 Thread Michel Desmoulin
While lambda are a great tools that can do the job of partial, partial is always a superior solution when trying to curry a Python function because it's explicit and easier to debug. Having to import it everytime means I usually go for a lambda out of lazyness, but also means that most people don'

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

2016-09-19 Thread Zachary Ware
On Mon, Sep 19, 2016 at 9:45 AM, eryk sun wrote: > On Mon, Sep 19, 2016 at 1:12 PM, Paul Moore wrote: >> By the way - if you're on a system with readline support included with >> Python, GNU readline apparently has a binding for clear-screen >> (CTRL-L) so you may well have this functionality alr

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

2016-09-19 Thread Oleg Broytman
On Mon, Sep 19, 2016 at 02:45:53PM +, eryk sun wrote: > The pInputControl parameter can also be used to implement Unix-style > Ctrl+D to end a read anywhere on a line, whereas the classic > [Ctrl+Z][Enter] has to be entered at the start of a line. [Ctrl+D] also recognized as EOF only at th

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

2016-09-19 Thread eryk sun
On Mon, Sep 19, 2016 at 1:12 PM, Paul Moore wrote: > By the way - if you're on a system with readline support included with > Python, GNU readline apparently has a binding for clear-screen > (CTRL-L) so you may well have this functionality already (I don;'t use > Unix or readline, so I can't comme

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

2016-09-19 Thread Paul Moore
On 19 September 2016 at 13:10, Paul Moore wrote: > > For this particular suggestion, though, I don't think that's the case. > I think it's going to either be something that's accepted into the > stdlib, or something that's rejected as too platform-specific or messy > to standardise, and people sho

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

2016-09-19 Thread Chris Angelico
On Mon, Sep 19, 2016 at 9:56 PM, Steven D'Aprano wrote: > On Mon, Sep 19, 2016 at 06:38:00PM +1000, Chris Angelico wrote: > >> Sounds good to me. This is definitely sounding complicated and messy >> enough to justify (a) writing a function to clear the screen, and (b) >> testing that function thor

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

2016-09-19 Thread Paul Moore
On 19 September 2016 at 12:56, Steven D'Aprano wrote: > > For relatively small pieces of functionality, if it is useful enough, we > should just add it to the std lib, and if it isn't, we should just say > it isn't useful enough. We shouldn't condemn supporters of the idea to > this false hope tha

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

2016-09-19 Thread Steven D'Aprano
On Mon, Sep 19, 2016 at 06:38:00PM +1000, Chris Angelico wrote: > Sounds good to me. This is definitely sounding complicated and messy > enough to justify (a) writing a function to clear the screen, and (b) > testing that function thoroughly as a PyPI module before pushing > anything into the stdl

[Python-ideas] ___repr__ on collections.UserDict, collections.UserList, collections.UserString

2016-09-19 Thread David Kendal
Hi, the UserDict, UserList, and UserString classes in the collections module ought to provide __repr__ implementations along the following lines: def __repr__(self): return '%s(%r)' % (type(self).__name__, self.data) so that they give useful immediate information in the repl to the effect

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

2016-09-19 Thread Terry Reedy
On 9/19/2016 4:31 AM, Paul Moore wrote: shutil.get_terminal_size() is available on all platforms. On windows, it works with Command Prompt and PowerShell but fails in IDLE, as it must. In the absence of knowledge, it guesses the default of 80 x 24 (as documented). AFAIK, there is no way wh

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

2016-09-19 Thread Chris Angelico
On Mon, Sep 19, 2016 at 6:31 PM, Paul Moore wrote: > On 19 September 2016 at 03:40, Chris Angelico wrote: >> On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano >> wrote: >>> (The fallback if all else fails is easy: get the height of the terminal, >>> in lines, and print that many blank lines.) >

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

2016-09-19 Thread Paul Moore
On 19 September 2016 at 03:40, Chris Angelico wrote: > On Mon, Sep 19, 2016 at 12:32 PM, Steven D'Aprano wrote: >> (The fallback if all else fails is easy: get the height of the terminal, >> in lines, and print that many blank lines.) > > Assuming you can get the height in lines. Have you tried t