But the foo() finds the function to call, so foo.bind() could be made to
find it too.
בתאריך יום ג׳, 20 בספט' 2016, 08:24, מאת 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 prob
Hi all,
I would like to add that I don't believe that discoverability is
always better in the `builtins' module.
I personally had the experience of going over itertools, where
I found 'zip_longest', but I couldn't find a 'zip_shortest'.
Only after some googling I found out it was called `zip' an
Hello,
You are correct.
Thanks for the explanation.
Best regards,
JM
terça-feira, 20 de Setembro de 2016 às 02:56:57 UTC+1, Steven D'Aprano
escreveu:
> 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 w
On Tue, Sep 20, 2016 at 5:01 PM, אלעזר wrote:
> But the foo() finds the function to call, so foo.bind() could be made to
> find it too.
class Demo:
def __init__(self):
self.bind = 42
def __call__(self):
print("I got called!")
foo = Demo()
You can most certainly call foo(
On Tue, Sep 20, 2016 at 4:56 AM Steven D'Aprano wrote:
> 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
On Tue, Sep 20, 2016 at 10:54 AM Chris Angelico wrote:
> On Tue, Sep 20, 2016 at 5:01 PM, אלעזר wrote:
> > But the foo() finds the function to call, so foo.bind() could be made to
> > find it too.
>
> class Demo:
> def __init__(self):
> self.bind = 42
> def __call__(self):
>
On Tue, Sep 20, 2016 at 6:09 PM, אלעזר wrote:
> I meant something like making it a "__bind__" (just a strawman suggestion)
> and do the same lookup as foo() does, and using a (wrong)
> functional-programming-inspired syntax
>
> foo 5 ()
>
> Such a syntax will have the side benefit of allowing
On 20 September 2016 at 08:57, אלעזר wrote:
> This is since in Python there are no contextual keywords (like "override"
> and "final" in C++). I remember encountering error in a Django project where
> accessing u.pass was a syntax error, but there *was* a field "pass" in u and
> they had to resort
Yeah I did say it was a strawman :)
On Tue, Sep 20, 2016 at 11:17 AM Chris Angelico wrote:
> On Tue, Sep 20, 2016 at 6:09 PM, אלעזר wrote:
> > I meant something like making it a "__bind__" (just a strawman
> suggestion)
> > and do the same lookup as foo() does, and using a (wrong)
> > functiona
On Tue, Sep 20, 2016 at 6:20 PM, Paul Moore wrote:
> There
> have been occasional deviations from this (for example, the "as" in
> "import foo as bar" was, for a time, only a keyword in that specific
> context) but I don't believe any of them survived long-term.
async and await are similarly cont
(Sorry, answered to one person again. Reposting)
I like the bind() idea because it doesn't clutter the builtin namespace.
It solves the import problem and feels very natural IMO.
The only issue is the name. In my mind, bind() convey the idea you are
modifying the function it self, while partial()
+1 for this. I regularly miss this feature.
Le 17/09/2016 à 13:12, João Matos a écrit :
> 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 usef
foo.__call__.partial() solves most of the problem I think.
בתאריך יום ג׳, 20 בספט' 2016, 12:43, מאת Michel Desmoulin <
desmoulinmic...@gmail.com>:
> (Sorry, answered to one person again. Reposting)
>
> I like the bind() idea because it doesn't clutter the builtin namespace.
> It solves the impor
On 19 September 2016 at 23:46, אלעזר wrote:
>> import pip
>> pip.install('attrs')
>> import attr
>
> Please forgive me for my ignorance, but it doesn't work as written - what's
> the actual method?
As David Mertz said, pip.main(['install', 'attrs']) works right now,
but it is NOT a supported use
On Tue, Sep 20, 2016 at 09:56:48AM +, אלעזר wrote:
> foo.__call__.partial() solves most of the problem I think.
There are two problems with that, one obvious and one subtle.
The obvious one is that __call__ is a dunder method, which means that
accessing it directly from outside of the object
I believe that at least some of these problems can be addressed given that
pip *knows* that this import is an in-script import. So the list of corner
cases will be shorter.
Elazar
On Tue, Sep 20, 2016 at 1:35 PM Paul Moore wrote:
> On 19 September 2016 at 23:46, אלעזר wrote:
> >> import pip
>
On 20 September 2016 at 00:28, אלעזר wrote:
> On Tue, Sep 20, 2016 at 2: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
>
On Tue, Sep 20, 2016 at 1:42 PM Paul Moore wrote:
> On 20 September 2016 at 00:28, אלעזר wrote:
> > On Tue, Sep 20, 2016 at 2:20 AM Stephen J. Turnbull
> > wrote:
> >>
> >> אלעזר writes:
> >>
> >> > Another use case, though I admit not the top priority of anyone here,
> >> is
> >> > that of a
On 20 September 2016 at 11:40, אלעזר wrote:
> I believe that at least some of these problems can be addressed given that
> pip *knows* that this import is an in-script import.
Not with pip as it is now. There's talk of detecting problem cases and
reporting back "you need to restart your Python se
On 20 September 2016 at 11:46, אלעזר wrote:
> So it should be something like
>
> from unsafe.__pip__ import benchmark
>
> Where unsafe is the hypothetical namespace in which exec(), eval() and
> subprocess.run() would have reside given your concerns.
In my opinion, it should be
# Please install
I think I generally understand concerns, and partially agree. I'm certainly
not dismissing them. I only try to understand what are the precise problems
and why the current situation - with dangerous functions at reach, easily
buried deep in the code instead of marked on the top of the script - is s
Moreover, being able to do it programmatically is a security risk, since it
requires elevated privileges that I don't know how to drop, and most people
will not think about doing, but a library implementation will.
So if someone uses subprocess.run(), and the system asks the user for
elevated priv
Le 20/09/2016 à 12:35, Paul Moore a écrit :
>
> While on the whole subject of this, I should also point out that there
> are a lot of potential issues with installing new packages while a
> Python program is running. They are all low-probability, and easy to
> avoid if you're not doing weird thin
On 20 September 2016 at 12:12, אלעזר wrote:
> Moreover, being able to do it programmatically is a security risk, since it
> requires elevated privileges that I don't know how to drop, and most people
> will not think about doing, but a library implementation will.
>
> So if someone uses subprocess
On Tue, Sep 20, 2016, at 07:12, אלעזר wrote:
> Moreover, being able to do it programmatically is a security risk,
> since it requires elevated privileges that I don't know how to drop,
> and most people will not think about doing, but a library
> implementation will.
Maybe we should be thinking ab
At last! Haven't used single dispatch exactly because of that. Thank you
savior!
+1
On Tue, Sep 20, 2016, 6:03 AM Tim Mitchell
wrote:
> 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
> (p
On 20 September 2016 at 13:58, Random832 wrote:
> On Tue, Sep 20, 2016, at 07:12, אלעזר wrote:
>> Moreover, being able to do it programmatically is a security risk,
>> since it requires elevated privileges that I don't know how to drop,
>> and most people will not think about doing, but a library
I am radically opposed to this proposal. Every time I see a partial
application I wonder endlessly about what's going on.
--Guido (mobile)
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of
Guido, can you please elaborate?
"What's going on" is usually that the same arguments are going to be passed
over and over again, and the programmer wanted to avoid this repetition.
The other option is adjusting the function to a predefined interface.
The alternative to partial is writing a closu
On Mon, Sep 19, 2016 at 06:18:38AM -0400, Terry Reedy wrote:
> 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.
Why "must" it fail?
What is it abou
On Tue, Sep 20, 2016 at 8:29 AM, אלעזר wrote:
> Guido, can you please elaborate?
>
> "What's going on" is usually that the same arguments are going to be
> passed over and over again, and the programmer wanted to avoid this
> repetition. The other option is adjusting the function to a predefined
On Tue, Sep 20, 2016 at 11:51 AM, Guido van Rossum
wrote:
> Also, I once timed it and could not show that partial was faster. This
> surprised me but it was what I measured (in one particular case).
I did similar timings on several occasions in the past and was also
surprised by the results. L
On Sep 20, 2016 10:52 AM, "Guido van Rossum" wrote:
>
> On Tue, Sep 20, 2016 at 8:29 AM, אלעזר wrote:
>> *snip*
>> The alternative to partial is writing a closure in the form of a
function, that needs to be carefully inspected to verify that it is indeed
just a partial application and not somethi
Le 20 sept. 2016 18:42, "Ryan Gonzalez" a écrit :
> Doing something like:
>
> lambda x, y: myfunc(partial_arg, x, y)
>
> is more error-prone to changes in myfunc's signature.
No, if the signature of the function changes, then the signature of the
partial would also change. The risk is the same.
I find myself "partializing" in ways partial() doesn't support more often
than not. E.g.
lambda first, third: myfunc(first, 42, third)
I think it's good to have partial() in functools, but it's two orders of
magnitude less common than things that should be in builtins.
On Sep 20, 2016 9:42 AM, "
I must admit I am a bit partial to partial, you can do fun things like this:
>>> from functools import partial
>>> @partial(partial, partial)
... def add(x, y):
... return x+y
...
>>> add(3)(4)
7
I suppose that isn't exactly going to convince Guide to put it in builtins,
though.
Stephan
2
I actually wrote the book _ Functional Programming in Python_, yet I
haven't the foggiest idea how to parse that code. A decorator parameterized
buy two instances of the decorator function itself?!
I know I could read the implementation and figure out why that works. But I
don't want to encourage
Paul Moore writes:
> I'm just saying that I don't want core Python to implicitly install
> packages for me.
+1
> But that's simply a personal opinion.
+0.5
It's not *purely* a personal opinion, though. The original proposal
is to include the facility and allow *script authors*, rather than
On Tue, Sep 20, 2016 at 9:18 PM Stephan Houben wrote:
> I must admit I am a bit partial to partial, you can do fun things like
> this:
>
> >>> from functools import partial
> >>> @partial(partial, partial)
> ... def add(x, y):
> ... return x+y
> ...
> >>> add(3)(4)
> 7
>
> I suppose that isn'
On Tue, Sep 20, 2016 at 9:48 PM Stephen J. Turnbull <
turnbull.stephen...@u.tsukuba.ac.jp> wrote:
> Paul Moore writes:
>
> > I'm just saying that I don't want core Python to implicitly install
> > packages for me.
>
> +1
>
> > But that's simply a personal opinion.
>
> +0.5
>
> It's not *purely*
On Wed, Sep 21, 2016 at 4:58 AM, אלעזר wrote:
> I think that combining user convenience and security considerations, there
> should be some way to invoke a GUI version of pip with flashing screen
> asking for permissions to install the library. In situations where
> interaction with the user is no
On 9/20/2016 11:51 AM, Guido van Rossum wrote:
We seem to have fundamentally different ideas of what sort of code is
most readable. The alternative to partial is usually a lambda,
Partial and lambda are different in that partial captures variable
values immediately, whereas lambda does not, u
On Wed, Sep 21, 2016 at 12:04 AM Terry Reedy wrote:
> On 9/20/2016 11:51 AM, Guido van Rossum wrote:
>
> ... (The greater flexibility of lambda, pointed out by David Mertz, is
> another.)
>
>
I just wanted to point out that the greater flexibility of lambda is a very
good reason *not* to choose i
As Ryan points out, pytest does this right. The way I understand it,
pytest is actively maintained and nose isn't. You should switch to pytest
as soon as possible.
Best,
Neil
On Saturday, September 17, 2016 at 8:55:43 PM UTC-4, Arek Bulski wrote:
>
> I am using declarative testing a lot and
On 9/20/2016 9:31 AM, Steven D'Aprano wrote:
On Mon, Sep 19, 2016 at 06:18:38AM -0400, Terry Reedy wrote:
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.
On Sun, Sep 18, 2016 at 02:52:31AM +0200, Arek Bulski wrote:
> I am using declarative testing a lot and I found out why unit tests are so
> clunky.
I don't think unit tests are clunky.
> The reason why assertEquals(a,b) is used is because if we put
> `assert a==b` then nose can catch the Asserti
On Tue, 20 Sep 2016 15:29:36 +, אלעזר wrote:
> The alternative to partial is writing a closure in the form of a
> function, that needs to be carefully inspected to verify that it is
> indeed just a partial application and not something more complex. It
> has more opportunity for introducing an
This class should be put somewhere. If you need it from inside a method,
you have to choose where to put it. If it is inside the method, it forces
the reader to scan it thoroughly to verify there's no "real" closure there,
and it also makes your methods significantly longer. If it is outside the
wh
Folks,
There are pros and cons of partial over lambda over classes, and which
you prefer may be at least in part a matter of subjective taste. But
Guido has spoken that he is virulently against making partial a builtin.
It really isn't hard to put "from functools import partial" at the top
of
On 21/09/2016 00:14, Neil Girdhar wrote:
As Ryan points out, pytest does this right. The way I understand it,
pytest is actively maintained and nose isn't. You should switch to
pytest as soon as possible.
Best,
Neil
Nose is no longer maintained but long live nose2
https://pypi.python.org/p
אלעזר wrote:
@partial(partial, partial(partial, partial))
def add(a, b, c): return a + b + c
For large numbers of arguments, it's much clearer if you
write it this way:
>>> from functools import partial as badger, partial as mushroom
>>> @badger(badger, badger(badger, badger(badger, mushroom))
Terry Reedy wrote:
In the default
mode with user code executed in a separate no-window process, there is
currently no way for the child process to know the current size of
Shell's tk text window in the parent process.
On unix it should be possible to let the child know if it's
connected throu
52 matches
Mail list logo