Re: [Python-ideas] Making Path() a built in.

2018-06-05 Thread Steven D'Aprano
On Tue, Jun 05, 2018 at 11:23:55PM -0700, Chris Barker wrote: > On Tue, Jun 5, 2018 at 4:42 PM, Steven D'Aprano wrote: > > > This is a quick and dirty survey of my code: [snip grepping] > I"m not saying I agree with the OP, but this is not a fair comparison at > all -- Path is pretty new, and eve

Re: [Python-ideas] Making Path() a built in.

2018-06-05 Thread Chris Barker via Python-ideas
On Tue, Jun 5, 2018 at 4:42 PM, Steven D'Aprano wrote: > This is a quick and dirty survey of my code: > > [steve@ando python]$ grep Path *.py */*.py */*/*.py | wc -l > 21 > [steve@ando python]$ grep "enumerate(" *.py */*.py */*/*.py | wc -l > 307 > [steve@ando python]$ grep "zip(" *.py */*.py */*

Re: [Python-ideas] Add dict.append and dict.extend

2018-06-05 Thread Chris Barker via Python-ideas
On Tue, Jun 5, 2018 at 4:10 PM, Steven D'Aprano wrote: > I'm confused... first you say that Ben makes a good case for this > functionality with the DB analogy, and then one sentence later, you say > the DB case is very different. So not a good case? I don't understand. > I wasn't trying to make

Re: [Python-ideas] Making Path() a built in.

2018-06-05 Thread Steven D'Aprano
On Tue, Jun 05, 2018 at 03:30:35PM +0200, Michel Desmoulin wrote: > There are very few programs that never use any path operation. On the contrary, there are many programs than never use any path operations. I have many programs which take input and provide output and no files are involved at a

Re: [Python-ideas] Add dict.append and dict.extend

2018-06-05 Thread Steven D'Aprano
On Tue, Jun 05, 2018 at 09:44:59AM -0700, Chris Barker via Python-ideas wrote: > I think your proposal got a bit confused by the choice of names, and that > you were proposing two things, one of which I think already exists > (setdefault). Ben's very first paragraph in this thread says: I'd

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread MRAB
On 2018-06-05 18:25, Kyle Lahnakoski wrote: I currently use the form     and log_function( ) where is some module variable, usually "DEBUG".  I do this because it is one line, and it ensures the log_function parameters are not evaluated. You'd get the same result with: if : log_f

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] Runtime assertion with no overhead when not active

2018-06-05 Thread Kyle Lahnakoski
I currently use the form     and log_function( ) where is some module variable, usually "DEBUG".  I do this because it is one line, and it ensures the log_function parameters are not evaluated. *IF* runtime assertions had a switch so they have no overhead when not active, how much faster can

Re: [Python-ideas] Add dict.append and dict.extend

2018-06-05 Thread Chris Barker via Python-ideas
I think your proposal got a bit confused by the choice of names, and that you were proposing two things, one of which I think already exists (setdefault). So, I _think_ what you are proposing is that there be a method something like: def exclusive_add(self, key, value): if key in self:

Re: [Python-ideas] Making Path() a built in.

2018-06-05 Thread Chris Barker - NOAA Federal via Python-ideas
Sorry for the top-post — iPhone email sucks. But: in regard to the whole “what paths to use to find resource files” issue: The “current working directory” concept can be very helpful. You put your files in a directory tree somewhere— could be inside the package, could be anywhere else. Then all

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread Eloi Gaudry
They are basically the same thing, with one difference being that runtime_assert would be used for extension mainly, and switchable on/off without using -o flag on the command line. Eloi From: Python-ideas on behalf of Michel Desmoulin Sent: Tuesday, June 5,

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

2018-06-05 Thread Yury Selivanov
Hi Michel, Yes, theoretically, it's possible to try to change an event loop policy while an event loop is running, but I've yet to see a library (or user code) that tries to do that (it's pointless anyways). There are libraries like uvloop that tell their users to explicitly install a special poli

[Python-ideas] Making Path() a built in.

2018-06-05 Thread Michel Desmoulin
There are very few programs that never use any path operation. Opening a file is such a common one we have a built-in for it with open(), but you usually need to do some manipulation to get the file path in the first place. We have __file__, but the most common usage is to get the parent dir, wit

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread Michel Desmoulin
Maybe somebody already answered this, but what's the difference between this and the keyword "assert", which basically can be stripped of using "python -o" ? Le 05/05/2018 à 10:04, Eloi Gaudry a écrit : > > Hi folks, > > > I intend to add a runtime assertion feature in python. Before >

[Python-ideas] Add hooks to asyncio lifecycle

2018-06-05 Thread Michel Desmoulin
After years of playing with asyncio, I'm still having a harder time using it than any other async architecture around. There are a lot of different reasons for it, but this mail want to address one particular one: The event loop and policy can be tweaked at any time, by anyone. Now, it's hard eno

Re: [Python-ideas] Make asyncio.get_event_loop a builtin

2018-06-05 Thread Michel Desmoulin
Well that doesn't matter anyway. With breakpoint() we choose the debugger implementation, so we could do the same here. However, this would be addressing the wrong problem the problem is verbosity. asyncio s are already aware of that, since they are working on providing asycio.run() in 3.7. Now t

Re: [Python-ideas] datetime.timedelta literals

2018-06-05 Thread Jacco van Dorp
i'd also be pretty simple to implement Just list: minute = timedelta(minutes=1) hour = timedelta(hours=1) etc... and you could import and use them like that. Or if you really want to write 5*m, the just from datetime import minute as m ___ Python-id

Re: [Python-ideas] datetime.timedelta literals

2018-06-05 Thread Robert Vanden Eynde
second, minute, hour (singular) timedelta objects in the module are a good idea, one could do 5 * minute to get a timedelta or one could do value / minute to get a float. a = datetime.now() b = datetime(2018, 2, 3) + 5 * minute print((a - b).total_seconds()) print((a - b) / minute) Le mar. 5 ju

Re: [Python-ideas] datetime.timedelta literals

2018-06-05 Thread Jacco van Dorp
2018-06-05 10:08 GMT+02:00 Pål Grønås Drange : >> You can't import literals. They're syntax, not just bound names. > > I'm way out of my comfort zone now, but the parser could for > `123.45_f` > give > `__literal_f__(123.45)` > and then that function should be imported. > > I'm sure this idea has m

Re: [Python-ideas] datetime.timedelta literals

2018-06-05 Thread Pål Grønås Drange
> You can't import literals. They're syntax, not just bound names. I'm way out of my comfort zone now, but the parser could for `123.45_f` give `__literal_f__(123.45)` and then that function should be imported. I'm sure this idea has many shortcomings that I don't see, but that was the reason why

Re: [Python-ideas] Allow popping of slices

2018-06-05 Thread Ben Rudiak-Gould
On Mon, Jun 4, 2018 at 5:11 PM, Steven D'Aprano wrote: > class MyList(list): > def pop(self, pos): > if isinstance(pos, slice): > temp = self[pos] > del self[pos] > return temp > return super().pop(pos) > > Is that what you have in mind? Yes