Re: [Python-ideas] Python-ideas Digest, Vol 131, Issue 106

2017-10-30 Thread Ivan Pozdeev via Python-ideas
On 31.10.2017 8:37, python-ideas-requ...@python.org wrote: On Tue, Oct 31, 2017 at 3:50 PM, Ivan Pozdeev via Python-ideas wrote: On 30.10.2017 17:32, Guido van Rossum wrote: This is a key example of a case where code speaks. Can you write an implementation of how you would want single() to wor

Re: [Python-ideas] Add processor generation to wheel metadata

2017-10-30 Thread Nathaniel Smith
On Mon, Oct 30, 2017 at 5:45 AM, Ivan Pozdeev via Python-ideas wrote: > Generally, packages are compiled for the same processor generation as the > corresponding Python. > But not always -- e.g. NumPy opted for SSE2 even for Py2 to work around some > compiler bug > (https://github.com/numpy/numpy/

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Nathaniel Smith
On Mon, Oct 30, 2017 at 10:25 AM, Alexander Belopolsky wrote: > On Mon, Oct 30, 2017 at 11:44 AM, Nick Coghlan wrote: > .. >> 3. We can't replicate it as readily in the regular REPL, since that runs >> Python code directly in the current process, but even there I believe we >> could potentially t

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Chris Angelico
On Tue, Oct 31, 2017 at 3:50 PM, Ivan Pozdeev via Python-ideas wrote: > On 30.10.2017 17:32, Guido van Rossum wrote: >> >> This is a key example of a case where code speaks. Can you write an >> implementation of how you would want single() to work in Python code? >> >> On Mon, Oct 30, 2017 at 2:49

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Ivan Pozdeev via Python-ideas
On 30.10.2017 17:32, Guido van Rossum wrote: This is a key example of a case where code speaks. Can you write an implementation of how you would want single() to work in Python code? On Mon, Oct 30, 2017 at 2:49 AM, Ivan Pozdeev via Python-ideas mailto:python-ideas@python.org>> wrote: Th

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Chris Barker - NOAA Federal
It's not 100% clear to me how my proposal below would work within a > Jupyter Notebook, so that would also be an angle worth looking into. > I'm -1 on this as I view it as a tooling issue, not a language issue. Agreed. And for the tool at hand, the notebook already controls the python interprete

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Steven D'Aprano
On Tue, Oct 31, 2017 at 07:51:02AM +1100, Cameron Simpson wrote: > return the(nodes) > > It's this kind of thing that expresses my intent better than the: > > node, = nodes > return node > > idiom. If the intent is to indicate that there is only one node, then "the(nodes)" fails completely

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Cameron Simpson
On 30Oct2017 07:32, Guido van Rossum wrote: This is a key example of a case where code speaks. Can you write an implementation of how you would want single() to work in Python code? Myself, I'm not advocating for putting such a thing in itertools. However, I do have an equivalent utility func

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Brett Cannon
On Mon, 30 Oct 2017 at 03:36 Erik Bray wrote: > On Mon, Oct 30, 2017 at 11:27 AM, Erik Bray wrote: > > On Sun, Oct 29, 2017 at 8:45 PM, Alex Walters > wrote: > >> Then those users have more fundamental problems. There is a minimum > level > >> of computer knowledge needed to be successful in p

Re: [Python-ideas] Defining an easily installable "Recommended baseline package set"

2017-10-30 Thread Guido van Rossum
So what's your list? What would you put in requirements.txt? I'm fine with doing it in the form of requirements.txt -- I am worried that when push comes to shove, we won't be able to agree on what list of package names should go into that file. On Mon, Oct 30, 2017 at 12:08 PM, Juancarlo Añez wro

Re: [Python-ideas] IMAP4.__exit__ counterintuitive for with blocks

2017-10-30 Thread Koos Zevenhoven
On Mon, Oct 30, 2017 at 8:30 PM, Drew wrote: > Yeah, a flag for IMAP4 objects sounds like it'd solve > backwards-compatibility problems. E.g. > > imaplib.IMAP4_SSL(..., commit=manual/auto) > > As for handling errors with automatic commits, we should probably just > defer to whatever Python IO doe

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Alex Walters
> -Original Message- > From: Python-ideas [mailto:python-ideas-bounces+tritium- > list=sdamon@python.org] On Behalf Of Erik Bray > Sent: Monday, October 30, 2017 6:28 AM > To: Python-Ideas > Subject: Re: [Python-ideas] install pip packages from Python prompt > > On Sun, Oct 29, 2017

Re: [Python-ideas] Thread.__init__ should call super()

2017-10-30 Thread Ilya Kulakov
Neil, thank you for doing much better job explaining the problem. Generally, I'm cool with Python's standard library classes not calling super(), as many of them are not designed for subclassing. But those which are should do that. E.g. take a look at more recent asyncio's Protocol and Transport

Re: [Python-ideas] Defining an easily installable "Recommended baseline package set"

2017-10-30 Thread Juancarlo Añez
On Mon, Oct 30, 2017 at 12:29 PM, Guido van Rossum wrote: > What's your proposed process to arrive at the list of recommended > packages? And is it really just going to be a list of names, or is there > going to be some documentation (about the vetting, not about the contents > of the packages) f

Re: [Python-ideas] IMAP4.__exit__ counterintuitive for with blocks

2017-10-30 Thread Drew
Yeah, a flag for IMAP4 objects sounds like it'd solve backwards-compatibility problems. E.g. imaplib.IMAP4_SSL(..., commit=manual/auto) As for handling errors with automatic commits, we should probably just defer to whatever Python IO does to remain consistent. ⁣ On Oct 30, 2017, 1:33 PM, at

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Stephan Houben
What about something like the following to simulate a "restart", portably. def restart(): import sys import os import subprocess if os.getenv("PYTHON_EXIT_ON_RESTART") == "1": sys.exit(42) else: env = os.environ.copy() env["PYTHON_EXIT_ON_RESTART"] = "1"

Re: [Python-ideas] IMAP4.__exit__ counterintuitive for with blocks

2017-10-30 Thread Guido van Rossum
But maybe if __exit__ is called with an exception it should roll back. In any case it looks like your proposal could break existing code (e.g. code that uses `with` depending on its current behavior, using some other logic to decide whether to commit or not) and that feels difficult to overcome. P

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Alexander Belopolsky
On Mon, Oct 30, 2017 at 11:44 AM, Nick Coghlan wrote: .. > 3. We can't replicate it as readily in the regular REPL, since that runs > Python code directly in the current process, but even there I believe we > could potentially trigger a full process restart via execve (or the C++ > style _execve o

[Python-ideas] IMAP4.__exit__ counterintuitive for with blocks

2017-10-30 Thread Drew
IMAP4.close closes the selected inbox and commits changes such as deletions. It is not called on IMAP4.__exit__ (only logout is, which doesn't call close in its call stack) however, so: with imaplib.IMAP4_SSL(...) as i:     ... would fail to commit those changes. close must be explicitly invoke

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Paul Moore
On 30 October 2017 at 16:22, Nick Coghlan wrote: >> Also, on Windows, I believe that any emulation of execve either leaves >> the original process in memory, or has problems getting console >> inheritance right. It's been a long time since I worked at that level, >> and things may be better now, b

Re: [Python-ideas] Defining an easily installable "Recommended baseline package set"

2017-10-30 Thread Guido van Rossum
What's your proposed process to arrive at the list of recommended packages? And is it really just going to be a list of names, or is there going to be some documentation (about the vetting, not about the contents of the packages) for each name? On Mon, Oct 30, 2017 at 9:08 AM, Nick Coghlan wrote:

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Antoine Pitrou
On Tue, 31 Oct 2017 02:22:50 +1000 Nick Coghlan wrote: > On 31 October 2017 at 02:06, Paul Moore wrote: > > > On 30 October 2017 at 15:53, Antoine Pitrou wrote: > > > On Tue, 31 Oct 2017 01:44:10 +1000 > > > Nick Coghlan wrote: > > >> (We'd want a real process restart, rather than emulatin

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Nick Coghlan
On 31 October 2017 at 02:06, Paul Moore wrote: > On 30 October 2017 at 15:53, Antoine Pitrou wrote: > > On Tue, 31 Oct 2017 01:44:10 +1000 > > Nick Coghlan wrote: > >> (We'd want a real process restart, rather than emulating it by calling > >> Py_Initialize & Py_Finalize multiple times, as not

Re: [Python-ideas] Defining an easily installable "Recommended baseline package set"

2017-10-30 Thread Nick Coghlan
On 31 October 2017 at 00:28, Guido van Rossum wrote: > I just feel that when you're talking about an org like PayPal they can > take care of themselves and don't need our help. They will likely have > packages they want installed everywhere that would never make in on your > list. So it feels thi

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Paul Moore
On 30 October 2017 at 15:53, Antoine Pitrou wrote: > On Tue, 31 Oct 2017 01:44:10 +1000 > Nick Coghlan wrote: >> >> A few specific notes here: >> >> 1. As you say, this sort of already works in notebooks, since instructors >> can say to run "!pip install requests" and then restart the language ke

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Antoine Pitrou
On Tue, 31 Oct 2017 01:44:10 +1000 Nick Coghlan wrote: > > A few specific notes here: > > 1. As you say, this sort of already works in notebooks, since instructors > can say to run "!pip install requests" and then restart the language kernel. > 2. We could probably replicate that style in IDLE,

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Nick Coghlan
On 30 October 2017 at 20:35, Erik Bray wrote: > I should add--another case that is becoming extremely common is > beginners learning Python for the first time inside the > Jupyter/IPython Notebook. And in my experience it can be very > difficult for beginners to understand the connection between

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Guido van Rossum
This is a key example of a case where code speaks. Can you write an implementation of how you would want single() to work in Python code? On Mon, Oct 30, 2017 at 2:49 AM, Ivan Pozdeev via Python-ideas < python-ideas@python.org> wrote: > > > On 30.10.2017 9:29, python-ideas-requ...@python.org wrot

Re: [Python-ideas] Defining an easily installable "Recommended baseline package set"

2017-10-30 Thread Guido van Rossum
I just feel that when you're talking about an org like PayPal they can take care of themselves and don't need our help. They will likely have packages they want installed everywhere that would never make in on your list. So it feels this whole discussion is a distraction and a waste of time (yours,

[Python-ideas] Add processor generation to wheel metadata

2017-10-30 Thread Ivan Pozdeev via Python-ideas
Generally, packages are compiled for the same processor generation as the corresponding Python. But not always -- e.g. NumPy opted for SSE2 even for Py2 to work around some compiler bug (https://github.com/numpy/numpy/issues/6428). I was bitten by that at an old machine once and found out that t

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Erik Bray
On Mon, Oct 30, 2017 at 11:27 AM, Erik Bray wrote: > On Sun, Oct 29, 2017 at 8:45 PM, Alex Walters wrote: >> Then those users have more fundamental problems. There is a minimum level >> of computer knowledge needed to be successful in programming. Insulating >> users from the reality of the sit

Re: [Python-ideas] install pip packages from Python prompt

2017-10-30 Thread Erik Bray
On Sun, Oct 29, 2017 at 8:45 PM, Alex Walters wrote: > Then those users have more fundamental problems. There is a minimum level > of computer knowledge needed to be successful in programming. Insulating > users from the reality of the situation is not preparing them to be > successful. Pretend

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Ivan Pozdeev via Python-ideas
On 30.10.2017 9:29, python-ideas-requ...@python.org wrote: If I have understood your use-case, you have a function that returns a list of results (or possibly an iterator, or a tuple, or some other sequence): print(search(haystack, needle)) # prints ['bronze needle', 'gold needle', '

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Stéfane Fermigier
IIUC, this would be similar to "first" ( https://pypi.python.org/pypi/first/ ) but would raise exception in case the iterable returns more than one (or less than one) element. Would also be similar to one() in SQLAlchemy queries ( http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.

Re: [Python-ideas] Composition over Inheritance

2017-10-30 Thread Thomas Jollans
On 29/10/17 19:25, Soni L. wrote: > > > On 2017-10-29 02:57 PM, Brendan Barnwell wrote: >> On 2017-10-29 04:44, Soni L. wrote: >>> And this is how you miss the whole point of being able to dynamically >>> add/remove arbitrary components on objects you didn't create, at >>> runtime. >>> >>> Someon

Re: [Python-ideas] Composition over Inheritance

2017-10-30 Thread Wes Turner
On Monday, October 30, 2017, Wes Turner wrote: > ... But interfaces are clunky and traits are lightweight, and this isn't > Go, so we can't just create a class as a namespace full of @staticmethods > which accept the relevant object references. > > * __setattribute__ -> __getitem__, __setitem__ >