Re: [Python-ideas] Syntax for allowing extra keys when unpacking a dict as keyword arguments

2019-04-12 Thread Nathaniel Smith
I don't think it's possible to make this work reliably. In particular, it's an important feature of python that you can make wrappers that pass through arguments and are equivalent to the original function: def original(a=0): ... def wrapper(*args, **kwargs): return original(*args, **kwar

Re: [Python-ideas] Sorted lists

2019-04-08 Thread Nathaniel Smith
On Mon, Apr 8, 2019, 02:09 Steven D'Aprano wrote: > On Sun, Apr 07, 2019 at 08:26:24PM -0700, Nathaniel Smith wrote: > > On Sun, Apr 7, 2019 at 7:37 PM Steven D'Aprano > wrote: > > > There are quite a few important algorithms which require lists to be > &

Re: [Python-ideas] Sorted lists

2019-04-07 Thread Nathaniel Smith
On Sun, Apr 7, 2019 at 7:37 PM Steven D'Aprano wrote: > There are quite a few important algorithms which require lists to be > sorted. For example, the bisect module, and for statistics median and > other quantiles. But this flag doesn't affect those modules, right? 'bisect' already requires the

Re: [Python-ideas] Add output() helper function to subprocess module

2019-04-04 Thread Nathaniel Smith
On Thu, Apr 4, 2019 at 1:59 AM Greg Ewing wrote: > > Nathaniel Smith wrote: > > On Thu, Apr 4, 2019 at 12:48 AM Greg Ewing > > wrote: > >>output(args) --> (status, output) > > > > Isn't this already available as: run(args, stdout=PIPE)? > &

Re: [Python-ideas] Add output() helper function to subprocess module

2019-04-04 Thread Nathaniel Smith
On Thu, Apr 4, 2019 at 12:48 AM Greg Ewing wrote: > > The check_output() function of the subprocess module raises an > exception if the process returns a non-zero exit status. This is > inconvenient for commands such as grep that use the return > status to indicate something other than success or

Re: [Python-ideas] Built-in parsing library

2019-04-01 Thread Nathaniel Smith
On Sun, Mar 31, 2019 at 9:17 PM Nam Nguyen wrote: > Installing a package out of stdlib does not solve the problem that motivated > this thread. The libraries included in the stdlib can't use those parsers. Can you be more specific about exactly which code in the stdlib you think should be rewrit

Re: [Python-ideas] New Project to Capture summaries from this

2019-03-28 Thread Nathaniel Smith
On Thu, Mar 28, 2019 at 4:52 PM Steven D'Aprano wrote: > On Thu, Mar 28, 2019 at 03:25:34PM -, Richard Whitehead wrote: > > Chris, > > > > As a new member to this list, I can tell you that searching for relevant old > > content was effectively impossible, so I'm all for some way of doing that.

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Nathaniel Smith
On Tue, Mar 26, 2019, 09:50 Richard Whitehead wrote: > Nathaniel, > > Thanks very much for taking the time to comment. > > Clearing the event after waiting for it will introduce a race condition: > if > the sender has gone around its loop again and set the semaphore after we > have woken but befo

Re: [Python-ideas] Simpler thread synchronization using "Sticky Condition"

2019-03-26 Thread Nathaniel Smith
These kinds of low-level synchronization primitives are notoriously tricky, yeah, and I'm all in favor of having better higher-level tools. But I'm not sure that AutoResetEvent adds enough to be worth it. AFAICT, you can get this behavior with an Event just fine – using your pseudocode: def sende

Re: [Python-ideas] unittest: 0 tests pass means failure of the testsuite

2019-03-06 Thread Nathaniel Smith
On Wed, Mar 6, 2019 at 12:13 PM Matěj Cepl wrote: > > Hi, > > I am a lead maintainer of Python packages in OpenSUSE and I can > see the pattern of many packagers adding blindly > > python setup.py test > > to %check section of our SPEC file. The problem is that if the > package doesn't use uni

Re: [Python-ideas] Allow creation of polymorph function (async function executable syncronously)

2019-03-06 Thread Nathaniel Smith
On Wed, Mar 6, 2019 at 4:37 PM pylang wrote: >> def maybe_async(fn): >> @functools.wraps(fn) >> def wrapper(*args, **kwargs): >> coro = fn(*args, **kwargs) >> if asyncio.get_running_loop() is not None: >> return coro >> else: >> return await

Re: [Python-ideas] Allow creation of polymorph function (async function executable syncronously)

2019-03-05 Thread Nathaniel Smith
Defining a single polymorphic function is easy at the library level. For example, with asyncio: def maybe_async(fn): @functools.wraps(fn) def wrapper(*args, **kwargs): coro = fn(*args, **kwargs) if asyncio.get_running_loop() is not None: return coro

Re: [Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-05 Thread Nathaniel Smith
On Mon, Mar 4, 2019 at 11:41 PM INADA Naoki wrote: > Then, I propose `dict.merge` method. It is outer-place version > of `dict.update`, but accepts multiple dicts. (dict.update() > can be updated to accept multiple dicts, but it's not out of scope). > > * d = d1.merge(d2) # d = d1.copy(); d.upd

Re: [Python-ideas] Potential PEP: with/except

2019-01-22 Thread Nathaniel Smith
The first concern that comes to my mind is... When I see: with: ... except: ... Is that a shorthand for try: with: ... except: ... or for with: try: ... except: ... ? Both are plausible, and it makes a big difference, because 'with' already has

Re: [Python-ideas] NAN handling in the statistics module

2019-01-06 Thread Nathaniel Smith
On Sun, Jan 6, 2019 at 11:06 PM Steven D'Aprano wrote: > I'm not wedded to the idea that the default ought to be the current > behaviour. If there is a strong argument for one of the others, I'm > listening. "Errors should never pass silently"? Silently returning nonsensical results is hard to de

Re: [Python-ideas] 回复:Python-ideas Digest, Vol 146, Issue 13

2019-01-05 Thread Nathaniel Smith
On Sat, Jan 5, 2019 at 9:13 PM Moon丶sun wrote: > > Thanks for your reply. > But the answer is not I except, I will show you some examples to explain what > result I except: > > @contextmanager > def cm(): > print('open file') > yield > print('close file') > with cm(): > 1/0 > > If

Re: [Python-ideas] struct.unpack should support open files

2018-12-26 Thread Nathaniel Smith
On Wed, Dec 26, 2018, 02:19 Andrew Svetlov > Also I'm thinking about type annotations in typeshed. > Now the type is Union[array[int], bytes, bytearray, memoryview] > Should it be Union[io.BinaryIO, array[int], bytes, bytearray, memoryview] ? > Yeah, trying to support both buffers and file-like o

Re: [Python-ideas] [asyncio] Suggestion for a major PEP

2018-12-16 Thread Nathaniel Smith
If you want this style of concurrency, you don't need to write a PEP, just 'pip install gevent' :-) But unfortunately you're years too late to argue for making asyncio work this way. This was discussed extensively at the time, and the decision to use special syntax was made intentionally, and afte

Re: [Python-ideas] Using sha512 instead of md5 on python.org/downloads

2018-12-07 Thread Nathaniel Smith
On Fri, Dec 7, 2018 at 3:38 PM Steven D'Aprano wrote: > On Fri, Dec 07, 2018 at 01:25:19PM -0800, Nathaniel Smith wrote: > > > For this specific purpose, md5 is just as good as a proper hash. But all > > else being equal, it would still be better to use a proper hash, j

Re: [Python-ideas] Using sha512 instead of md5 on python.org/downloads

2018-12-07 Thread Nathaniel Smith
For this specific purpose, md5 is just as good as a proper hash. But all else being equal, it would still be better to use a proper hash, just so people don't have to go through the whole security analysis to check that. Of course all else isn't equal: switching from md5 to sha-whatever would requ

Re: [Python-ideas] Enhancing range object string displays

2018-11-19 Thread Nathaniel Smith
On Mon, Nov 19, 2018 at 6:09 PM Steven D'Aprano wrote: > > On Mon, Nov 19, 2018 at 05:09:25PM -0800, danish bluecheese wrote: > > I think it is kind of useless effort. If somebody using range() then > > probably knows about it. > > For experienced users, sure, but this is an enhancement to help >

Re: [Python-ideas] Relative Imports

2018-11-13 Thread Nathaniel Smith
On Fri, Nov 9, 2018 at 4:32 PM, danish bluecheese wrote: > you are right on the lines you mentioned. Those are all working if i run it > as a module which i do every time. > This is somewhat unpleasant to me, especially while developing something and > trying to test it quickly. > I just want to b

Re: [Python-ideas] Standardising ASGI as a PEP

2018-10-27 Thread Nathaniel Smith
The WSGI PEP is a bit of a funny thing, since it's a PEP that doesn't really involve the language or stdlib. (I guess there's wsgiref, but I don't think it being in the stdlib actually affects much these days.) What are you hoping to accomplish by making ASGI a PEP? -n On Sat, Oct 27, 2018 at 4:

Re: [Python-ideas] Contracts in python -- a report & next steps

2018-10-25 Thread Nathaniel Smith
On Thu, Oct 25, 2018, 14:44 Marko Ristin-Kaufmann wrote: > > Nathaniel Smith wrote: > >> In your position, I wouldn't be talking to the core devs; I'd be >> writing blog posts to proselytize the advantages of contracts, working >> with popular projects

Re: [Python-ideas] Contracts in python -- a report & next steps

2018-10-24 Thread Nathaniel Smith
On Wed, Oct 24, 2018 at 11:23 AM, Marko Ristin-Kaufmann wrote: > I imagine that you conceive contracts purely as an approach to a testing to > be applied to a single project. I'm not talking about that. I'm talking > about two packages on pypi, both specifying contracts, each developed by a > sepa

Re: [Python-ideas] Add closing and iteration to threading.Queue

2018-10-22 Thread Nathaniel Smith
On Sun, Oct 21, 2018 at 8:31 PM, Guido van Rossum wrote: > On Sun, Oct 21, 2018 at 6:08 PM Nathaniel Smith wrote: >> I'm not sure if this is an issue the way Queue is used in practice, but in >> general you have to be careful with this kind of circular flow because if >&g

Re: [Python-ideas] Add closing and iteration to threading.Queue

2018-10-21 Thread Nathaniel Smith
On Sun, Oct 21, 2018, 16:48 MRAB wrote: > On 2018-10-21 22:30, Antoine Pitrou wrote: > > On Sun, 21 Oct 2018 19:58:05 +0200 > > Vladimir Filipović > > wrote: > >> > >> To anticipate a couple more possible questions: > >> > >> - What would this proposal do about multiple producers/consumers > >>

Re: [Python-ideas] Add closing and iteration to threading.Queue

2018-10-21 Thread Nathaniel Smith
Hi Vladimir, It's great to see people revisiting these old stdlib tools. Closure tracking is definitely a big point of awkwardness for Queues. In Trio we started with a straight copy of threading.Queue, and this turned out to be a major friction point for users. We just deprecated our version of Q

Re: [Python-ideas] support toml for pyproject support

2018-10-08 Thread Nathaniel Smith
On Mon, Oct 8, 2018 at 2:55 AM, Steven D'Aprano wrote: > > On Mon, Oct 08, 2018 at 09:10:40AM +0200, Jimmy Girardet wrote: >> Each tool which wants to use pyproject.toml has to add a toml lib as a >> conditional or hard dependency. >> >> Since toml is now the standard configuration file format, >

Re: [Python-ideas] Support parsing stream with `re`

2018-10-07 Thread Nathaniel Smith
On Sun, Oct 7, 2018 at 5:54 PM, Nathaniel Smith wrote: > Are you imagining something roughly like this? (Ignoring chunk > boundary handling for the moment.) > > def find_double_line_end(buf): > start = 0 > while True: > next_idx = buf.index(b"\n", s

Re: [Python-ideas] Support parsing stream with `re`

2018-10-07 Thread Nathaniel Smith
On Sun, Oct 7, 2018 at 5:09 PM, Terry Reedy wrote: > On 10/6/2018 5:00 PM, Nathaniel Smith wrote: >> >> On Sat, Oct 6, 2018 at 12:22 AM, Ram Rachum wrote: >>> >>> I'd like to use the re module to parse a long text file, 1GB in size. I >>> wish &g

Re: [Python-ideas] Support parsing stream with `re`

2018-10-07 Thread Nathaniel Smith
On Sat, Oct 6, 2018, 18:40 Steven D'Aprano wrote: > The message I take from this is: > > - regex engines certainly can be written to support streaming data; > - but few of them are; > - and it is exceedingly unlikely to be able to easily (or at all) > retro-fit that support to Python's existing

Re: [Python-ideas] Support parsing stream with `re`

2018-10-06 Thread Nathaniel Smith
On Sat, Oct 6, 2018 at 2:04 PM, Chris Angelico wrote: > On Sun, Oct 7, 2018 at 8:01 AM Nathaniel Smith wrote: >> >> On Sat, Oct 6, 2018 at 12:22 AM, Ram Rachum wrote: >> > I'd like to use the re module to parse a long text file, 1GB in size. I >> > wish

Re: [Python-ideas] Support parsing stream with `re`

2018-10-06 Thread Nathaniel Smith
On Sat, Oct 6, 2018 at 12:22 AM, Ram Rachum wrote: > I'd like to use the re module to parse a long text file, 1GB in size. I wish > that the re module could parse a stream, so I wouldn't have to load the > whole thing into memory. I'd like to iterate over matches from the stream > without keeping

Re: [Python-ideas] Debugging: some problems and possible solutions

2018-10-03 Thread Nathaniel Smith
On Wed, Oct 3, 2018 at 10:48 AM, Chris Angelico wrote: > On Thu, Oct 4, 2018 at 2:30 AM Anders Hovmöller wrote: >> >> Nothing is a keyword in that example or in my example. My suggestion is that >> we could do: >> >> my_func(=big_array[5:20]) >> >> And it would be compile time transformed into >

Re: [Python-ideas] f-string "debug" conversion

2018-10-03 Thread Nathaniel Smith
On Wed, Oct 3, 2018, 03:55 Eric V. Smith wrote: > > On 10/3/2018 1:40 AM, Nathaniel Smith wrote: > > I think the way I'd do it would be: > > > > Step 1: Take the current "lnotab" that lets us map bytecode offsets -> > > line numbers, and exte

Re: [Python-ideas] f-string "debug" conversion

2018-10-02 Thread Nathaniel Smith
On Tue, Oct 2, 2018 at 8:44 PM, David Teresi wrote: > print(f'{value!d}') is a lot of symbols and boilerplate to type out just for > a debugging statement that will be deleted later. Especially now that > breakpoint() exists, I can't really see myself using this. > > I also don't see the use case

Re: [Python-ideas] Suggestion: Extend integers to include iNaN

2018-09-28 Thread Nathaniel Smith
On Fri, Sep 28, 2018 at 11:31 PM, Steve Barnes wrote: > One specific use case that springs to mind would be for Libraries such > as Pandas to return iNaN for entries that are not numbers in a column > that it has been told to treat as integers. Pandas doesn't use Python objects to store integers,

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-13 Thread Nathaniel Smith
On Thu, Sep 13, 2018 at 9:13 AM, Mark E. Haase wrote: > On Thu, Sep 13, 2018 at 10:49 AM Rhodri James wrote: > >> More importantly, this whole idea of banning and/or changing terminology >> is psychologically and sociologically wrong-headed. The moment you say "You >> may not use that word" you

Re: [Python-ideas] Asynchronous friendly iterables

2018-08-20 Thread Nathaniel Smith
On Mon, Aug 20, 2018 at 12:34 AM, Simon De Greve wrote: > Do you mean that for loops inside an "async def" statements are always > executed as 'async for' loops? That's what I wanted to acheive by writing > the AsyncDict class (c.f. the CodeReview link). The only difference between an 'async for'

Re: [Python-ideas] Asynchronous friendly iterables

2018-08-20 Thread Nathaniel Smith
On Mon, Aug 20, 2018 at 12:19 AM, Simon De Greve wrote: > Hello everyone, > > I'm quite new working with asyncio and thus maybe missing some things about > it, but wouldn't it be quite easier to have some iterables to support async > for loops "natively", since asyncio is now part of the Stdlib? >

Re: [Python-ideas] Make "yield" inside a with statement a SyntaxError

2018-08-08 Thread Nathaniel Smith
On Tue, Aug 7, 2018 at 11:14 PM, Ken Hilton wrote: > This mostly springs off of a comment I saw in some thread. > > The point of a with statement is that it ensures that some resource will be > disposed of, yes? For example, this: > > with open(filename) as f: > contents = f.read() > >

Re: [Python-ideas] Adding Python interpreter info to "pip install"

2018-07-19 Thread Nathaniel Smith
On Thu, Jul 19, 2018 at 5:45 PM, Al Sweigart wrote: > The goal of this idea is to make it easier to find out when someone has > installed packages for the wrong python installation. I'm coming across > quite a few StackOverflow posts and emails where beginners are using pip to > install a package,

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-18 Thread Nathaniel Smith
On Wed, Jul 18, 2018 at 11:49 AM, Stephan Houben wrote: > Basically, what I am suggesting is a direct translation of Javascript's > Web Worker API > (https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API) > to Python. > > The Web Worker API is generally considered a "share-nothing" appr

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-15 Thread Nathaniel Smith
On Sun, Jul 15, 2018 at 6:00 PM, Chris Angelico wrote: > On Mon, Jul 16, 2018 at 10:31 AM, Nathaniel Smith wrote: >> On Sun, Jul 8, 2018 at 11:27 AM, David Foster wrote: >>> * The Actor model can be used with some effort via the “multiprocessing” >>> module, but it do

Re: [Python-ideas] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-15 Thread Nathaniel Smith
On Sun, Jul 8, 2018 at 11:27 AM, David Foster wrote: > * The Actor model can be used with some effort via the “multiprocessing” > module, but it doesn’t seem that streamlined and forces there to be a > separate OS process per line of execution, which is relatively expensive. What do you mean by "

Re: [Python-ideas] Add new `Symbol` type

2018-07-05 Thread Nathaniel Smith
On Thu, Jul 5, 2018 at 1:25 PM, Flavio Curella wrote: > >> What functionality does such a thing actually need? > > I think the requirements should be: > * The resulting symbol behave exactly like None. IE: the symbol should not > be an instance of object, but an instance of its own class > * A sym

Re: [Python-ideas] Add a __cite__ method for scientific packages

2018-06-28 Thread Nathaniel Smith
On Thu, Jun 28, 2018 at 2:25 PM, Andrei Kucharavy wrote: >> This is indeed a serious problem. I suspect python-ideas isn't the >> best venue for addressing it though – there's nothing here that needs >> changes to the Python interpreter itself (I think), and the people who >> understand this probl

Re: [Python-ideas] Add a __cite__ method for scientific packages

2018-06-27 Thread Nathaniel Smith
On Wed, Jun 27, 2018 at 2:20 PM, Andrei Kucharavy wrote: > To remediate to that situation, I suggest a __citation__ method associated > to each package installation and import. Called from the __main__, > __citation__() would scan __citation__ of all imported packages and return > the list of all

Re: [Python-ideas] Replacing Infinite while Loops with an Iterator: async edition

2018-06-23 Thread Nathaniel Smith
On Sat, Jun 23, 2018 at 5:58 PM, Greg Ewing wrote: > j...@math.brown.edu wrote: >> >> it would be nice if we could write an async version of this, as in ``async >> for chunk in aiter(...)``. > > The time machine seems to have taken care of this: > > https://docs.python.org/3.6/reference/compound_s

Re: [Python-ideas] Secure string disposal (maybe other inmutable seq types too?)

2018-06-22 Thread Nathaniel Smith
On Fri, Jun 22, 2018 at 6:45 PM, Steven D'Aprano wrote: > On Sat, Jun 23, 2018 at 01:33:59PM +1200, Greg Ewing wrote: >> Chris Angelico wrote: >> >Downside: >> >You can't say "I'm done with this string, destroy it immediately". >> >> Also it would be hard to be sure there wasn't another >> copy of

Re: [Python-ideas] Copy (and/or pickle) generators

2018-06-19 Thread Nathaniel Smith
You might find this useful, either to use directly or as a source of inspiration: https://github.com/ll/cloudpickle-generators -n On Tue, Jun 19, 2018, 15:55 Micheál Keane wrote: > > Add a function to generator objects to copy the entire state of it: > > Proposed example code: > > game

Re: [Python-ideas] Approximately equal operator

2018-06-15 Thread Nathaniel Smith
On Fri, Jun 15, 2018 at 3:56 PM, Andre Roberge wrote: > * people doing heavy numerical work and wanting code as readable as possible IME serious numerical work doesn't use approximate equality tests at all, except in test assertions. > * teaching mostly beginners about finite precision for float

Re: [Python-ideas] Fwd: Trigonometry in degrees

2018-06-12 Thread Nathaniel Smith
On Tue, Jun 12, 2018, 00:03 Stephan Houben wrote: > Hi all, > > I wrote a possible implementation of sindg: > > https://gist.github.com/stephanh42/336d54a53b31104b97e46156c7deacdd > > This code first reduces the angle to the [0,90] interval. > After doing so, it can be observed that the simple im

Re: [Python-ideas] Add hooks to asyncio lifecycle

2018-06-05 Thread Nathaniel Smith
Twisted's reactor API has some lifecycle hooks: https://twistedmatrix.com/documents/18.4.0/api/twisted.internet.interfaces.IReactorCore.html#addSystemEventTrigger My impression is that this is actually pretty awkward for twisted/asyncio interoperability, because if you're trying to use a twisted

Re: [Python-ideas] Async Lambda syntax

2018-05-18 Thread Nathaniel Smith
On Fri, May 18, 2018 at 1:53 PM, Noah Simon wrote: > Hello all, > I was developing a script using an asyncio-based API, when I came across the > need to define an asynchronous lambda. I found this syntax does not > currently exist. Obviously I could have (and did) just write a regular > coroutine,

Re: [Python-ideas] High Precision datetime

2018-05-17 Thread Nathaniel Smith
On Thu, May 17, 2018 at 9:49 AM, Chris Barker via Python-ideas wrote: > On Tue, May 15, 2018 at 11:21 AM, Rob Speer wrote: >> >> >> I'm sure that the issue of "what do you call the leap second itself" is >> not the problem that Chris Barker is referring to. The problem with leap >> seconds is tha

Re: [Python-ideas] Crazy idea: allow keywords as names in certain positions

2018-05-13 Thread Nathaniel Smith
On Sun, May 13, 2018 at 9:00 PM, Greg Ewing wrote: > Guido van Rossum wrote: >> >> Of course this would still not help for names of functions that might be >> imported directly (do people write 'from numpy import where'?). > > > Maybe things could be rigged so that if you use a reserved word > as

Re: [Python-ideas] High Precision datetime

2018-05-10 Thread Nathaniel Smith
You don't mention the option of allowing time.microseconds to be a float, and I was curious about that since if it did work, then that might be a relatively smooth extension of the current API. The highest value you'd store in the microseconds field is 1e6, and at values around 1e6, double-precisio

Re: [Python-ideas] Please consider skipping hidden directories in os.walk, os.fwalk, etc.

2018-05-09 Thread Nathaniel Smith
There are hidden directories, and then there are hidden directories :-). It makes sense to me to add an option to the stdlib functions to skip directories (and files) that the system considers hidden, so I guess that means dotfiles on Unix and files with the hidden attribute on Windows. But if you

Re: [Python-ideas] __dir__ in which folder is this py file

2018-05-07 Thread Nathaniel Smith
On Mon, May 7, 2018, 03:45 Steven D'Aprano wrote: > On Sun, May 06, 2018 at 09:33:03PM -0700, Nathaniel Smith wrote: > > > How is > > > > data_path = __filepath__.parent / "foo.txt" > > > > more distracting than > > > > data_

Re: [Python-ideas] __dir__ in which folder is this py file

2018-05-06 Thread Nathaniel Smith
On Sun, May 6, 2018 at 8:47 PM, Nick Coghlan wrote: > On 7 May 2018 at 13:33, Nathaniel Smith wrote: >> >> Spit-balling: how about __filepath__ as a >> lazily-created-on-first-access pathlib.Path(__file__)? >> >> Promoting os.path stuff to builtins just as pathli

Re: [Python-ideas] __dir__ in which folder is this py file

2018-05-06 Thread Nathaniel Smith
Spit-balling: how about __filepath__ as a lazily-created-on-first-access pathlib.Path(__file__)? Promoting os.path stuff to builtins just as pathlib is emerging as TOOWTDI makes me a bit uncomfortable. On Sun, May 6, 2018 at 8:29 PM, Nick Coghlan wrote: > On 7 May 2018 at 12:35, Chris Angelico

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-04 Thread Nathaniel Smith
On Fri, May 4, 2018 at 6:56 PM, Alexander Belopolsky wrote: > On Fri, May 4, 2018 at 8:06 AM, Nick Coghlan wrote: >> ... >> With that spelling, the three examples above would become: >> >> # Exactly one branch is executed here >> if m given m = pattern.search(data): >> ... >>

Re: [Python-ideas] Auto-wrapping coroutines into Tasks

2018-05-04 Thread Nathaniel Smith
On Fri, May 4, 2018 at 2:58 PM, Guido van Rossum wrote: > First, "start executing immediately" is an overstatement, right? They won't > run until the caller executes a (possibly unrelated) `await`. Well, traditional Future-returning functions often do execute some logic immediately, but right, wh

[Python-ideas] Auto-wrapping coroutines into Tasks

2018-05-04 Thread Nathaniel Smith
Hi all, This is a bit of a wacky idea, but I think it might be doable and have significant benefits, so throwing it out there to see what people think. In asyncio, there are currently three kinds of calling conventions for asynchronous functions: 1) Ones which return a Future 2) Ones which retur

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-04 Thread Nathaniel Smith
On Fri, May 4, 2018 at 1:53 PM, Tim Peters wrote: > [Tim] >>> ... >>> It's no longer the case that Python avoided that entirely, since >>> "async def", "async for", and "async with" statements were added >>> _without_ making "async" a new reserved word. It may require pain in >>> the parser, but

Re: [Python-ideas] Objectively Quantifying Readability

2018-05-01 Thread Nathaniel Smith
On Tue, May 1, 2018, 02:55 Matt Arcidy wrote: > > I am not inferring causality when creating a measure. No, but when you assume that you can use that measure to *make* code more readable, then you're assuming causality. Measuring the > temperature of a steak doesn't infer why people like it me

Re: [Python-ideas] Objectively Quantifying Readability

2018-05-01 Thread Nathaniel Smith
On Mon, Apr 30, 2018 at 8:46 PM, Matt Arcidy wrote: > On Mon, Apr 30, 2018 at 5:42 PM, Steven D'Aprano wrote: >> (If we know that, let's say, really_long_descriptive_identifier_names >> hurt readability, how does that help us judge whether adding a new kind >> of expression will hurt or help read

Re: [Python-ideas] Should __builtins__ have some kind of pass-through print function, for debugging?

2018-04-28 Thread Nathaniel Smith
On Sat, Apr 28, 2018 at 7:29 PM, Greg Ewing wrote: > but he sent it in HTML using a proportional font, which spoils the effect! Uh...? https://vorpus.org/~njs/tmp/monospace.png It looks like my client used "font-family: monospace", maybe yours only understands or something? Anyway, if anyone el

Re: [Python-ideas] Should __builtins__ have some kind of pass-through print function, for debugging?

2018-04-28 Thread Nathaniel Smith
On Fri, Apr 27, 2018 at 5:58 AM, Chris Angelico wrote: > On Fri, Apr 27, 2018 at 9:27 PM, Steven D'Aprano wrote: > I don't think this needs any specific compiler magic or making 'dp' a > reserved name, but it might well be a lot easier to write if there > were some compiler features provided to _

[Python-ideas] Should __builtins__ have some kind of pass-through print function, for debugging?

2018-04-27 Thread Nathaniel Smith
Hi all, This came up in passing in one of the PEP 572 threads, and I'm curious if folks think it's a good idea or not. When debugging, sometimes you have a somewhat complicated expression that's not working: # Hmm, is func2() returning the right thing? while (func1() + 2 * func2()) < func3():

Re: [Python-ideas] Providing a public API for creating and parsing HTTP messages

2018-04-17 Thread Nathaniel Smith
On Mon, Apr 16, 2018 at 11:21 PM, Derek Maciel wrote: > The modules http.client and http.server both do a wonderful job when > implementing HTTP clients and servers, respectively. However, occasionally > there may be a need to create and parse HTTP messages themselves without > needing to implemen

Re: [Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

2018-03-20 Thread Nathaniel Smith
On Tue, Mar 20, 2018 at 1:03 AM, Wes Turner wrote: > I added trio to the comparison table > (Things are mostly just async-wrapped, > though pathlib_not_trio does show a few missing methods?). trio.Path is an automatically generated, exact mirror of pathlib.Path, so I don't think it's very useful

Re: [Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

2018-03-18 Thread Nathaniel Smith
On Sun, Mar 18, 2018 at 4:58 AM, George Fischhof wrote: > Of course several details could be put into it, but I think it would better > to let the developers decide the details, because they know the environment > and the possibilities. That's not how PEPs work :-). Someone has to do the work of

Re: [Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

2018-03-17 Thread Nathaniel Smith
On Sat, Mar 17, 2018 at 10:15 AM, Stephen J. Turnbull wrote: > (5) perform operations on several objects denoted by Paths at once > (copy and its multiple operand variants), Sure it does: Path.rename and Path.replace. I know why rename and copy have historically been in separate modules, but

Re: [Python-ideas] Adding quantile to the statistics module

2018-03-16 Thread Nathaniel Smith
On Fri, Mar 16, 2018 at 11:19 PM, Stephen J. Turnbull wrote: > PLIQUE Guillaume writes: > > > That's really interesting. I did not know there were so many way to > > consider quantiles. Maybe we should indeed wait for numpy to take a > > decision on the matter and go with their default choice s

Re: [Python-ideas] Adding quantile to the statistics module

2018-03-15 Thread Nathaniel Smith
On Thu, Mar 15, 2018 at 12:39 PM, PLIQUE Guillaume wrote: > Hello everyone, > > Sorry if this subject has already been covered in the mailing list but I > could not find it. > > My question is very simple: should the `quantile` function be added to > python `statistics` module. This seems like a

Re: [Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

2018-03-14 Thread Nathaniel Smith
On Mar 12, 2018 1:57 PM, "George Fischhof" wrote: This PEP proposes pathlib module to be a centralized place for all file-system related operations. I'd find this useful for another reason that hasn't been mentioned yet: having a single class collecting all the common/basic file operations make

Re: [Python-ideas] Add MutableSet.update?

2018-03-10 Thread Nathaniel Smith
On Sat, Mar 10, 2018 at 2:45 PM, Chris Barker wrote: > On Sat, Mar 10, 2018 at 3:24 AM, MRAB wrote: >> >> On 2018-03-10 01:15, Guido van Rossum wrote: >>> >>> Yes, you can use the |= operator instead. >>> >> |= is not quite the same as .update because it rebinds, > > > isn't that an "in-place ope

Re: [Python-ideas] Class autoload

2018-03-03 Thread Nathaniel Smith
On Sat, Mar 3, 2018 at 9:12 AM, Jamesie Pic wrote: > > Hello everybody, > > I thought perhaps we could allow the usage of a "new" keyword to instanciate > an object, ie: > >obj = new yourmodule.YourClass() > > In this case, it would behave the same as from yourmodule import YourClass; > obj =

Re: [Python-ideas] Consider making Decimal's context use PEP 567

2018-02-07 Thread Nathaniel Smith
On Feb 7, 2018 1:54 PM, "Neil Girdhar" wrote: Decimal could just pull its Context object from a context variable rather than having to pass it in to all functions. This would be similar to how numpy works. Decimal has always used a thread local context the same way numpy does, and in 3.7 it's

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Nathaniel Smith
On Sun, Jan 28, 2018 at 5:31 PM, David Mertz wrote: > I actually didn't know about `locale.format("%d", 10e9, grouping=True)`. > But it's still much less general than having the option in the > f-string/.format() mini-language. This is really about the formatted > string, not necessarily about th

Re: [Python-ideas] Format mini-language for lakh and crore

2018-01-28 Thread Nathaniel Smith
On Sun, Jan 28, 2018 at 5:46 AM, Eric V. Smith wrote: > If I recall correctly, we discussed this at the time, and the problem with > locale is that it's not thread safe. I agree that if it were, it would be > nice to be able to use it, either with 'n', or in some other mode just for > grouping. >

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-18 Thread Nathaniel Smith
On Thu, Jan 18, 2018 at 7:51 PM, Guido van Rossum wrote: > Can someone explain to me why this is such a controversial issue? I guess practicality versus purity is always controversial :-) > It seems reasonable to me to add new encodings to the stdlib that do the > roundtripping requested in the

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-17 Thread Nathaniel Smith
On Wed, Jan 17, 2018 at 10:13 AM, Rob Speer wrote: > I'm going to push back on the idea that this should only be used for > decoding, not encoding. > > The use case I started with -- showing people how to fix mojibake using > Python -- would *only* use these codecs in the encoding direction. To fi

Re: [Python-ideas] Support WHATWG versions of legacy encodings

2018-01-11 Thread Nathaniel Smith
On Jan 11, 2018 4:05 AM, "Antoine Pitrou" wrote: Define "widely used". If web-XXX is a superset of windows-XXX, then perhaps web-XXX is "used" in the sense of "used to decode valid windows-XXX data" (but windows-XXX could be used just as well to decode the same data). The question is rather: ho

Re: [Python-ideas] make Connections iterable

2018-01-09 Thread Nathaniel Smith
On Jan 9, 2018 04:12, "Random832" wrote: On Tue, Jan 9, 2018, at 05:46, Nick Coghlan wrote: > If you view them as comparable to subprocess pipes, then it can be > surprising that they're not iterable when using a line-oriented > protocol. > > If you instead view them as comparable to socket conne

Re: [Python-ideas] make Connections iterable

2018-01-09 Thread Nathaniel Smith
On Tue, Jan 9, 2018 at 2:07 AM, Antoine Pitrou wrote: > On Mon, 8 Jan 2018 21:22:56 -0800 > Nathaniel Smith wrote: >> >> The only documented error from multiprocessing.Connection.recv is EOFError, >> which is basically equivalent to a StopIteration. > > Actual

Re: [Python-ideas] make Connections iterable

2018-01-08 Thread Nathaniel Smith
On Mon, Jan 8, 2018 at 7:27 PM, Amit Green wrote: > An argument against this API, is that any caller of recv should be doing > error handling (i.e.: catching exceptions from the socket). > It's still not entirely clear, but I'm pretty sure this thread is talking about multiprocessing.Connection

Re: [Python-ideas] Deprecate "slice" on built-ins, move it to "types"?

2017-12-28 Thread Nathaniel Smith
On Dec 28, 2017 12:10, "Joao S. O. Bueno" wrote: This is probably too little to justify the compatibility breakage, but is there a motive for the "slice" type to be on built-ins ? (besides people forgot it there at PEP-3000 time?) It is normally used in super-specialized cases, mostly when one

Re: [Python-ideas] a sorting protocol dunder method?

2017-12-04 Thread Nathaniel Smith
On Sun, Dec 3, 2017 at 10:48 PM, Carl Meyer wrote: > It'd be nice to be able to eliminate an import and have the lines of > code and instead write that as: > > class BankAccount: > def __init__(self, balance): > self.balance = balance > > def __sort_key__(self): >

Re: [Python-ideas] Using an appropriate tone in emails (was: Adding a thin wrapper class around the functions in stdlib.heapq)

2017-11-27 Thread Nathaniel Smith
On Mon, Nov 27, 2017 at 7:22 PM, bunslow wrote: > My first submission to this list was predicated on what I'd read in PEPs -- > and many of those, since they recommend major-enough changes to require a > PEP, have sections (often lengthy) dedicated to "what's wrong with the > status quo". My attem

Re: [Python-ideas] Looking for input to help with the pip situation

2017-11-14 Thread Nathaniel Smith
On Tue, Nov 14, 2017 at 12:56 AM, Paul Moore wrote: > On 14 November 2017 at 03:08, Nathaniel Smith wrote: >> On Nov 13, 2017 6:47 PM, "Nick Coghlan" wrote: > >>> and a pip.bat with the equivalent contents on Windows? >>> (Bonus: maybe this wou

Re: [Python-ideas] Looking for input to help with the pip situation

2017-11-13 Thread Nathaniel Smith
On Nov 13, 2017 6:47 PM, "Nick Coghlan" wrote: On 14 November 2017 at 11:51, Nathaniel Smith wrote: > What if instead of installing a standard entry point, the pip > executable was installed as > > #!/bin/sh > exec python -m pip "$@" > > on Unix-likes I

Re: [Python-ideas] Looking for input to help with the pip situation

2017-11-13 Thread Nathaniel Smith
On Sun, Nov 12, 2017 at 8:59 AM, Brendan Barnwell wrote: > On 2017-11-12 05:18, Nick Coghlan wrote: >> >> * the `pip install` option really is nicer looking than `python -m pip >> install`, and it only has actual problems in the presence of multiple >> Python versions and when upgrading pip itself

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

2017-11-02 Thread Nathaniel Smith
On Wed, Nov 1, 2017 at 2:47 PM, Terry Reedy wrote: > When pip installs a package into site_packages, does it at any point run > package-specific installation code? setup.py? Nope. That's a can of worms that we've so far avoided opening. > More specifically, can pip > install an IDLE extension.

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

2017-11-01 Thread Nathaniel Smith
On Wed, Nov 1, 2017 at 7:41 AM, Guido van Rossum wrote: > Can you write 1-2 paragraphs with the argument for each? > > On Tue, Oct 31, 2017 at 10:01 PM, Nathaniel Smith wrote: >> - lxml My impression (probably others are more knowledgeable) is that lxml has more or less replaced

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

2017-10-31 Thread Nathaniel Smith
On Oct 31, 2017 4:42 AM, "Nick Coghlan" wrote: On 31 October 2017 at 02:29, Guido van Rossum wrote: > What's your proposed process to arrive at the list of recommended packages? > I'm thinking it makes the most sense to treat inclusion in the recommended packages list as a possible outcome of

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/

  1   2   >