Re: [Python-ideas] Efficient debug logging

2017-02-15 Thread Barry Scott
> On 15 Feb 2017, at 02:39, Kyle Lahnakoski wrote: > > > On 2017-02-14 19:51, Abe Dillon wrote: >> The point is that the cost of creating the msg argument can be very high. >> >> At the point that logging decides to skip output it is to late to save >> the

Re: [Python-ideas] Efficient debug logging

2017-02-15 Thread Barry Scott
On Wednesday, 15 February 2017 22:18:31 GMT Steven D'Aprano wrote: > On Tue, Feb 14, 2017 at 03:51:05PM +0000, Barry Scott wrote: > > A common pattern I use is to have logging calls for debug and information > > with my applications. The logging calls can be separately enabled a

Re: [Python-ideas] Efficient debug logging

2017-02-15 Thread Barry Scott
On Wednesday, 15 February 2017 22:33:42 GMT Chris Angelico wrote: > On Wed, Feb 15, 2017 at 10:18 PM, Steven D'Aprano wrote: > > Python doesn't have thunks, but there is a relatively heavyweight > > solution for delayed evaluation: wrap the code in a function. > > > >

Re: [Python-ideas] Efficient debug logging

2017-02-15 Thread Barry Scott
On Tuesday, 14 February 2017 22:00:31 GMT Barry wrote: > > On 14 Feb 2017, at 17:39, Kyle Lahnakoski wrote: > > > > > > Can you wrap the expensive functions in lambdas? And have your logger > > evaluate it, only if required? > > > >> debugLog( ‘info is %r’ % (lambda:

Re: [Python-ideas] Efficient debug logging

2017-02-16 Thread Barry Scott
ve messages) that is otherwise > easily addressed by custom logic. Agreed if this specific use case is solved by a general mechanism that is fantastic. > > On 16.02.2017, 5:47 Barry Scott wrote: > __repr__ is interesting however. > > Typically I describe in a string w

Re: [Python-ideas] Efficient debug logging

2017-02-16 Thread Barry Scott
ed. I guess at that point its the same as using the lambda but you have the syntax sugar of Steven’s <# … #>. Barry > On 15 Feb 2017, at 16:46, Sven R. Kunze <srku...@mail.de> wrote: > > On 15.02.2017 12:55, Barry Scott wrote: >> The lazy eval sound like a gener

Re: [Python-ideas] Add pathlib.Path.write_json andpathlib.Path.read_json

2017-03-29 Thread Barry Scott
> On 27 Mar 2017, at 15:08, Markus Meskanen wrote: > > -1, should we also include write_ini, write_yaml, etc? > Markus, You illustrate why this is a bad design pattern to implement. It does not scale. I attended a talk at PYCON UK that talked to the point of using

Re: [Python-ideas] Exploiting type-homogeneity in list.sort() (again!)

2017-03-09 Thread Barry Scott
> On 8 Mar 2017, at 22:58, Elliot Gorokhovsky > wrote: > > On Wed, Mar 8, 2017 at 2:14 PM Barry > wrote: > Can you assume that list of of type(list[0]) and use that type's optimised > sort? > But in the

Re: [Python-ideas] Proposal: making __str__ count in time's class

2017-03-08 Thread Barry Scott
> On 8 Mar 2017, at 16:01, Francesco Franchina wrote: > > Hello everyone, > > I'm shortly writing to you about a reflection I lately made upon the current > functioning of __str__ for the time's class. > > Before expressing my thought and proposal, I want to make sure we

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-20 Thread Barry Scott
> On 19 Jun 2017, at 13:56, Nick Coghlan <ncogh...@gmail.com> wrote: > > On 19 June 2017 at 04:10, Barry Scott <ba...@barrys-emacs.org> wrote: >> The code does this: >> >>Py::Object getattro( const Py::String _ ) >>{ >>

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-20 Thread Barry Scott
> On 19 Jun 2017, at 13:56, Nick Coghlan <ncogh...@gmail.com> wrote: > > On 19 June 2017 at 04:10, Barry Scott <ba...@barrys-emacs.org> wrote: >> The code does this: >> >>Py::Object getattro( const Py::String _ ) >>{ >>

[Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-13 Thread Barry Scott
I have been trying to get dir(c_ext_obj) to work for PyCXX as the method used with python2 was removed in python3, namely use the list of names returned from the __members__ attribute. I have failed to find a simple replacement for the python3 API. It seems that I have implement __dir__. But

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-14 Thread Barry Scott
> On 13 Jun 2017, at 23:49, Chris Angelico wrote: > > On Wed, Jun 14, 2017 at 8:09 AM, Terry Reedy wrote: >> Perhaps you are looking for __dir__, called by dir(). >> >> " dir([object]) >> >>Without arguments, return the list of names in the current

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-15 Thread Barry Scott
> On 15 Jun 2017, at 04:45, Nick Coghlan <ncogh...@gmail.com> wrote: > > On 15 June 2017 at 11:06, Nathaniel Smith <n...@pobox.com > <mailto:n...@pobox.com>> wrote: >> On Wed, Jun 14, 2017 at 1:54 PM, Barry Scott <ba...@barrys-emacs.org> wrote: >>

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-18 Thread Barry Scott
> On 16 Jun 2017, at 09:46, Nick Coghlan <ncogh...@gmail.com> wrote: > > On 16 June 2017 at 07:44, Barry Scott <ba...@barrys-emacs.org> wrote: >> But I need the result of __dir__ for my object not its base. Then I need to >> add in the list of member attribute

Re: [Python-ideas] ImportError raised for a circular import

2017-06-18 Thread Barry Scott
> On 18 Jun 2017, at 19:21, Barry Scott <ba...@barrys-emacs.org> wrote: > >> >> On 14 Jun 2017, at 07:33, Nick Coghlan <ncogh...@gmail.com >> <mailto:ncogh...@gmail.com>> wrote: >> >> On 14 June 2017 at 13:02, Mahmoud Hashemi <ma

Re: [Python-ideas] ImportError raised for a circular import

2017-06-18 Thread Barry Scott
> On 14 Jun 2017, at 07:33, Nick Coghlan wrote: > > On 14 June 2017 at 13:02, Mahmoud Hashemi wrote: >> That would be amazing! If there's anything I can do to help make that >> happen, please let me know. It'll almost certainly save that much time for

[Python-ideas] ImportError raised for a circular import

2017-06-13 Thread Barry Scott
Recently I fell into the trap of creating a circular import and yet again it took time to figure out what was wrong. I'm wondering why the python import code does not detect this error and raise an exception. I took a look at the code and got as far as figuring out that I would need to add

Re: [Python-ideas] A PEP to define basical metric which allows to guarantee minimal code quality

2017-09-19 Thread Barry Scott
> On 17 Sep 2017, at 19:17, alexandre.gal...@gmail.com wrote: > > Hi, > > thanks for your answer, and your questions. Very good draw. I printed it in > my office ^^ > > First i'd like to precise that, as in title, aim is not to gurantee quality > but minimal quality. I think it's really two

Re: [Python-ideas] A PEP to define basical metric which allows to guarantee minimal code quality

2017-09-20 Thread Barry Scott
> On 20 Sep 2017, at 20:02, alexandre.gal...@gmail.com wrote: > > Hi, > > Thanks to everyone for your contribution to my proposal. > > @Barry, I agree with you that each organisation needs to integrate the > "quality process" in their workflow. But before integrate it, this "quality" >

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

2017-12-04 Thread Barry Scott
I wondered what the performance would be and tested the following code: #!/usr/bin/env python3 import random import time random.seed( hash('Testing Keys') ) lt_calls = 0 key_calls = 0 class MyObject: def __init__( self, value1, value2 ): self.value1 = value1 self.value2 =

Re: [Python-ideas] Moving typing out of the stdlib in Python 3.7?

2017-11-05 Thread Barry Scott
On Saturday, 4 November 2017 20:22:25 GMT Guido van Rossum wrote: > On Sat, Nov 4, 2017 at 7:05 AM, Nick Coghlan wrote: > > Perhaps typing could switch to being a bundled module, such that it > > had its own version, independent of the Python standard library > > version, but

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

2017-12-06 Thread Barry Scott
> On 5 Dec 2017, at 01:06, Chris Barker wrote: > > wow! a few time zones (and a day job) really make a difference to taking part > in a discussion :-) > > This could be a good idea -- just putting it here for the record as it's > mentioned elsewhere. > > I can't

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

2018-05-10 Thread Barry Scott
> On 7 May 2018, at 18:52, Guido van Rossum wrote: > > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka > wrote: > I just don't understand why you need a new keyword for writing runtime checks. > > Oh, that's pretty clear.

[Python-ideas] keywords and backward compatibility

2018-05-13 Thread Barry Scott
There seems to be a recurring theme of ideas wanting a new keyword but not being able to have one because of backwards compatibility. What if I have a way to ask for the new keyword? Would that make it easier to accept and implement some of the new ideas? The "given" keyword for example could be

Re: [Python-ideas] shutil zero-copy and exotic filesystems

2018-05-29 Thread Barry Scott
On Tuesday, 29 May 2018 16:42:13 BST Eric Fahlgren wrote: snip... > On our WAN, which has a VPN endpoint 3000 miles from our office, routing > back to a test server another 2000 miles inside the network (tracert shows > 12-15 hops, 200 ms latency, arrrg), copying is slow no matter what: we are >

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

2018-06-06 Thread Barry Scott
I assume the the idea is that everybody has Path available without the need to do the import dance first. If its for personal convenience you can always do this trick, that is used by gettext to make _ a builtin. import pathlib import builtings builtins.__dict__['Path'] = pathlib.Path Now

Re: [Python-ideas] Allow to compile debug extension against releasePython in Windows

2018-01-09 Thread Barry Scott
> On 9 Jan 2018, at 20:35, Ivan Pozdeev <v...@mail.mipt.ru> wrote: > > On 09.01.2018 23:31, Barry Scott wrote: >> I not a user of distutils or setuptools but some googling seems to say that >> the build command has a --debug to do what you want. If that does not >

Re: [Python-ideas] Allow to compile debug extension against releasePython in Windows

2018-01-09 Thread Barry Scott
I not a user of distutils or setuptools but some googling seems to say that the build command has a --debug to do what you want. If that does not work it would seem like you could ask the setuptools maintainers how to do the reason thing of a debug build. Barry > On 9 Jan 2018, at 18:46, Ivan

Re: [Python-ideas] Why CPython is still behind in performance for some widely used patterns ?

2018-02-01 Thread Barry Scott
> On 30 Jan 2018, at 05:45, Nick Coghlan wrote: > > I'll also note that one of the things we (and others) *have* been > putting quite a bit of time into is the question of "Why do people > avoid using extension modules for code acceleration?". I think that is simple. Those

Re: [Python-ideas] a set of enum.Enum values rather than the construction of bit-sets as the "norm"?

2018-01-01 Thread Barry Scott
I'm guessing that what this thread is about is coming up with an API rule that makes providing a set of boolean options available to a function or class in the least error prone way. Its the error prone nature of integer bit masks that is behind the enum suggestion I assume. >From the C

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

2018-08-08 Thread Barry Scott
On Wednesday, 8 August 2018 07:14:47 BST Ken Hilton wrote: > Now, let's take a look at the following scenario: > > def read_multiple(*filenames): > for filename in filenames: > with open(filename) as f: > yield f.read() In this particular case you can fix

Re: [Python-ideas] File format for automatic and manual tests

2018-08-08 Thread Barry Scott
On Tuesday, 7 August 2018 22:57:51 BST Victor Porton wrote: > This is an idea of a new PEP. > > I propose to create a portable file format which will list command line > options to run Python scripts with dual purpose: At the moment I solve this problem with various solutions, depending on

Re: [Python-ideas] Off topic: 'strike a balance' - second language English

2018-08-20 Thread Barry Scott
> On 20 Aug 2018, at 17:07, Chris Barker via Python-ideas > wrote: > > > Summary: I look at the phrase 'strike a balance' in different languages, > > It is interesting that you picked up on "strike a balance" which has > been a standard English phrase for a very long time rather than the

Re: [Python-ideas] A GUI for beginners and experts alike

2018-08-24 Thread Barry Scott
> On 23 Aug 2018, at 19:49, Mike Barnett wrote: > > Python has dropped the GUI ball, at least for beginners (in my opinion) > > While the Python language is awesomely compact, the GUI code is far from > compact. Tkinter will create a nice looking GUI, but you’ve got to be > skilled to use

Re: [Python-ideas] A GUI for beginners and experts alike (Mike Barnett)

2018-08-24 Thread Barry Scott
> On 23 Aug 2018, at 23:14, Hugh Fisher wrote: > >> Date: Thu, 23 Aug 2018 18:49:48 + >> From: Mike Barnett >> >> Python has dropped the GUI ball, at least for beginners (in my opinion) >> >> While the Python language is awesomely compact, the GUI code is far from >> compact. Tkinter

Re: [Python-ideas] Multi-core reference count garbage collection

2018-07-21 Thread Barry Scott
> On 21 Jul 2018, at 08:54, Jonathan Fine wrote: > > Hi Steve > > Thank you for your message. I think my response below allows us to go move > forward. > > WHAT'S THE PROBLEM > You asked: > > What problem are you trying to solve? > > Its okay if there is no immediate problem, that you're

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

2018-07-21 Thread Barry Scott
Eric, > On 17 Jul 2018, at 20:35, Eric Snow wrote: > > With this in mind, here's how I'm approaching the problem: > > 1. interp A "shares" an object with interp B (e.g. through a channel) >* the object is incref'ed under A before it is sent to B > 2. the object is wrapped in a proxy owned

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

2018-07-18 Thread Barry Scott
> On 18 Jul 2018, at 08:21, Ronald Oussoren wrote: > > Op 18 jul. 2018 om 08:02 heeft Barry > het volgende geschreven: > >> >> On 17 Jul 2018, at 21:00, Eric Snow wrote: On Tue, Jul 17, 2018 at 1:44 PM Barry wrote: The decrement itself

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

2018-07-18 Thread Barry Scott
> On 17 Jul 2018, at 21:00, Eric Snow wrote: > > On Tue, Jul 17, 2018 at 1:44 PM Barry wrote: >> The decrement itself is not the problem, that can be made thread safe. > > Yeah, by using the GIL. Otherwise, please elaborate. My > understanding is that if the decrement itself were not the

Re: [Python-ideas] Calling python from C completely statically

2018-07-09 Thread Barry Scott
I think you might find Gordon McMillian's installer interesting to look at. It has a lot f the tech that I think you are looking for. Works up to python 2.7. I ended up taking over when Gordon stopped maintaining it and kept it going up to python 2.7. In principle the same ideas could be made

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

2018-03-18 Thread Barry Scott
It seems that the main quest to answer first is this. Should Path() have methods to access all file operations? Maybe it was a mistake to add the ones that are already there. Especially in light of the fspath protocol that now exists. If yes proceed to details the methods and their semantics.

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

2018-03-18 Thread Barry Scott
> On 18 Mar 2018, at 17:50, Jason Maldonis wrote: > > Maybe this is obvious or I am missing something crucial, but I'm surprised > that this hasn't been discussed yet: > > From a user perspective, imo the problem is that users currently need three > modules (pathlib,

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

2018-03-18 Thread Barry Scott
> On 18 Mar 2018, at 11:58, George Fischhof wrote: > > Hi Folks, > > it seems for me that the welcoming of this proposal is rather positive than > not. I think that is up for debate. > > Of course several details could be put into it, but I think it would better > to

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

2018-03-21 Thread Barry Scott
On Tuesday, 20 March 2018 16:22:57 GMT Brett Cannon wrote: > On Mon, 19 Mar 2018 at 18:08 Chris Barker wrote: > > [SNIP] > > PS: does shutil really still not work with Path objects? aarrgg! > > Did you verify this or are you just guessing? If this is true then file a > bug

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-24 Thread Barry Scott
> On 23 Sep 2018, at 11:13, Angus Hollands wrote: > > Hi Marko, > > I think there are several ways to approach this problem, though am not > weighing in on whether DbC is a good thing in Python. I wrote a simple > implementation of DbC which is currently a run-time checker. You could, with

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-24 Thread Barry Scott
> On 23 Sep 2018, at 11:33, Hugh Fisher wrote: > > Could it be that Python has better libraries, is faster to develop for, > attracts > more programmers? If so, I suggest it's worth considering that this might > be *because* Python doesn't have DbC. I'm not sure how you get from the lack of

Re: [Python-ideas] Why is design-by-contracts not widely adopted?

2018-09-24 Thread Barry Scott
ontact dpcontracts maintainers. Maybe it's possible to at least > merge a couple of libraries into one and make it a de facto standard. @Agnus, > would you also like to join the effort? > > Cheers, > Marko > > > > > > Le lun. 24 sept. 2018 à 19:57, Barry

Re: [Python-ideas] Fixed point format for numbers with locale based separators

2019-01-05 Thread Barry Scott
On Friday, 4 January 2019 14:57:53 GMT Łukasz Stelmach wrote: > Hi, > > I would like to present two pull requests[1][2] implementing fixed point > presentation of numbers and ask for comments. The first is mine. I > learnt about the second after publishing mine. > > The only format using decimal

Re: [Python-ideas] tkinter: time for round buttons?

2019-01-16 Thread Barry Scott
> On 16 Jan 2019, at 16:11, Abdur-Rahmaan Janhangeer > wrote: > > without starting a should we ban tkinter discussion, i'd like to propose that > we add rounded corners buttons. that might make the aesthetic level go up a > bit more > > poor me, if only py had some really nice native gui

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

2019-01-22 Thread Barry Scott
> On 22 Jan 2019, at 20:11, Paul Ferrell wrote: > > I've found that almost any time I'm writing a 'with' block, it's doing > something that could throw an exception. As a result, each of those > 'with' blocks needs to be nested within a 'try' block. Due to the > nature of 'with', it is rarely

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

2019-01-22 Thread Barry Scott
> On 22 Jan 2019, at 20:31, Michael Selik wrote: > > On Tue, Jan 22, 2019, 12:11 PM Paul Ferrell wrote: > I see this as the natural evolution of what 'with' is all about - replacing > necessary try-finally blocks with something more elegant. We just didn't >

Re: [Python-ideas] Backtick expression: similar to a shorter lambda syntax

2019-01-22 Thread Barry Scott
The problem with using the back-tick is that it is far too easy to miss read it for a single-quote. back-tick in bash has the $( xxx ) replacement that avoids the problem. Please find an alternative syntax that avoid the problem. Barry > On 22 Jan 2019, at 13:42, James Lu wrote: > > Later

Re: [Python-ideas] Use lazy loading with hashtable in python gettext module

2018-12-18 Thread Barry Scott
> On 18 Dec 2018, at 09:10, Serge Ballesta via Python-ideas > wrote: > > In a project of mine, I have used the gettext module from Python Standard > Library. I have found that several tools could be used to generate the > Machine Object (mo) file from the source Portable Object (one):

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

2018-12-09 Thread Barry Scott
On Windows 10 this works: c:Downloads> certutil -hashfile python-3.7.1-amd64.exe sha512 SHA512 hash of python-3.7.1-amd64.exe: 7dec6362c402b38a9c29b85b204398d7d3fd19509f05279bf713a92abe5b485d4c0c4b175c4edb47f81fd800a599bc2283642a8f0c666edd9e971b5cedf18041 CertUtil: -hashfile command completed

Re: [Python-ideas] New explicit methods to trim strings

2019-04-03 Thread Barry Scott
Use "without" as the action picking up on "with" as in startswith, endswith: new_string = a_string.withoutprefix( prefix ) new_string = a_sring.withoutsuffix( suffix ) And since we have "replace" "remove" would also seem obvious. new_string = a_string.removeprefix(

Re: [Python-ideas] Add list.join() please

2019-01-30 Thread Barry Scott
> On 30 Jan 2019, at 10:07, Jamesie Pic wrote: > > On Wed, Jan 30, 2019 at 7:03 AM Robert Vanden Eynde > wrote: >>> >>> Raises an error. Why should: >>> >>> “”.join([2, “2”]) not raise an error as well? >> >> I agree > > What do you think could be the developer intent when they do >

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

2019-04-09 Thread Barry Scott
Nam, I'm not so sure that a "universal parsing library" is possible for the stdlib. I think one way you could find out what the requirements are is to refactor at least 2 of the existing stdlib modules that you have identified as needing a better parser. Did you find that you could use the

Re: [Python-ideas] Sorted lists

2019-04-08 Thread Barry Scott
> On 8 Apr 2019, at 19:37, Terry Reedy wrote: > > On 4/8/2019 5:40 AM, Steven D'Aprano wrote: >> On Mon, Apr 08, 2019 at 07:44:41AM +0100, Alex Chamberlain wrote: >>> I think a better abstraction for a sorted list is a new class, which >>> implements the Sequence protocol (and hence can be

Re: [Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

2019-05-26 Thread Barry Scott
> On 26 May 2019, at 08:07, Yanghao Hua wrote: > > On Sun, May 26, 2019 at 12:04 AM David Mertz wrote: >> >> I don't really understand HDL/Verilog, but I've worked with people who do. >> In fact, I even wrote a pre-processor that transformed the same DSL to >> Python, C++, and Verilog. >>

Re: [Python-ideas] Operator as first class citizens -- like in scala -- or yet another new operator?

2019-05-26 Thread Barry Scott
> On 26 May 2019, at 17:04, Yanghao Hua wrote: > > On Sun, May 26, 2019 at 11:27 AM Barry Scott wrote: >> I think you are confusing the number of people that use HDL with the amount >> of product created. > > I don't see how I did that but if you intercepted

Re: [Python-ideas] Implement POSIX ln via shutil.link and shutil.symlink

2019-05-30 Thread Barry Scott
> On 30 May 2019, at 01:49, Steven D'Aprano wrote: > > On Wed, May 29, 2019 at 10:22:31PM +0100, Barry wrote: > >> Serhiy, I think, is conflating two things. >> 1. How to write software robust aginst attack. >> 2. How to replace a symlink atomically. > > I don't have an opinion on whether

[Python-ideas] Re: Operator as first class citizens -- like in scala -- or yet another new operator?

2019-06-11 Thread Barry Scott
> On 11 Jun 2019, at 09:50, Yanghao Hua wrote: > > On Mon, Jun 10, 2019 at 8:57 PM Caleb Donovick > wrote: >> >> First off, I have admittedly not read all of this thread. However, as >> designer of DSL's in python, I wanted to jump in on a couple of things

[Python-ideas] Re: Add «iterate non-blocking» wrapper to prevent blocking loop too long

2019-06-15 Thread Barry Scott
> On 15 Jun 2019, at 10:55, Gustavo Carneiro wrote: > > > Perhaps. But using threads is more complicated. You have to worry about the > integrity of your data in the face of concurrent threads. And if inside your > task you sometimes need to call async coroutine code, again you need to

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Barry Scott
> On 16 May 2019, at 11:05, Serhiy Storchaka wrote: > > 16.05.19 11:28, Barry Scott пише: >> To replace one symlink with another atomically is possible by using rename() >> or renameat() >> something like: >> os.symlink( src, tmp_symlink ) &g

Re: [Python-ideas] shutil.symlink to allow non-race replacement of existing link targets

2019-05-16 Thread Barry Scott
To replace one symlink with another atomically is possible by using rename() or renameat() something like: os.symlink( src, tmp_symlink ) os.rename( tmp_symlink, dst ) Use dir_fd's to taste. I'm sure there is a lot more to cover all the corner cases and attack vectors. I'm not

Re: [Python-ideas] easier lazy logging in stdlib ?

2019-05-16 Thread Barry Scott
This came up 2 years ago. You might want to read this article on LWN that covered the discussion. https://lwn.net/Articles/716986/ Assuming that the log code you call will spot a callable and call it you can do this: log_function( lambda :

Re: [Python-ideas] Idea: Allow multiple levels of tracers

2019-04-28 Thread Barry Scott
> On 25 Apr 2019, at 15:51, Ram Rachum wrote: > > Hi, > > Here's something I want in Python: Multiple levels of tracers working on top > of each other, instead of just one. > > I'm talking about the tracer that one can set by calling sys.settrace. > > I've recently released PySnooper:

Re: [Python-ideas] Idea: Allow multiple levels of tracers

2019-04-28 Thread Barry Scott
> On 28 Apr 2019, at 09:12, Ram Rachum wrote: > > It's possible, but it would be very cumbersome, for a bunch of reasons. One > of them is that the tracing code inspects the frame, the variables referenced > in it, and it even opens the file of the code object of the frame. It will be >

[Python-ideas] Re: Suggestion: Windows launcher default to not using pre-releases by default

2019-07-10 Thread Barry Scott
> On 10 Jul 2019, at 21:13, Steve Barnes wrote: > > Brett, > > Can I suggest that it might be an idea to add the honouring of PY_PYTHON and > PY_PYTHON2 environmental variables to the help text. This is the missing > piece as far as I am concerned. I knew about the py.ini but not the env

[Python-ideas] Re: Python including packages

2019-07-08 Thread Barry Scott
> On 8 Jul 2019, at 12:19, Xavier Combelle wrote: > > Fifth, as far as I understand the core reason of the initial talk is that > twisted will support forever python 2, and as such demand that the whole > python ecosystem find workaround to allow this attitude. As I understand it Twisted

[Python-ideas] Re: PEP: add a `no` keyword as an alias for `not`

2019-08-02 Thread Barry Scott
I did a quick scan of the source code I have checkout. I see "no" as a variable in Python, PyPy, GitPython and setuptools. Adding "no" as a keyword will break at least those projects. Barry Here are the details: Python3/Lib/distutils/tests/test_util.py 249 no = ('n', 'no', 'f',

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Barry Scott
> On 1 Aug 2019, at 19:11, Guido van Rossum > wrote: > > This is an interesting phenomenon. I'm not saying it's good or bad, I'm just > observing it (because it surprised me). Here is someone declaring that the > docs are less accessible than the code. I personally

[Python-ideas] Re: [OT] Designing for Concurrency (was: Add a "block" option to Executor.submit)

2019-09-07 Thread Barry Scott
> On 5 Sep 2019, at 20:43, Andrew Barnert wrote: > > Have you actually needed case 3 with Executor, or only with other kinds of > async models? With other kinds of async. I mention it as this looks like a design pattern for this problem space. Barry

[Python-ideas] Re: Universal parsing library in the stdlib to alleviate security issues

2019-07-21 Thread Barry Scott
> On 19 Jul 2019, at 02:12, Nam Nguyen wrote: > > > I'm working on the impact of CVE-2019-9636 as part of my day-job. > > I'd be interesting in your analysis of how you parsing proposal would have > avoided this problem before it was described. > I add the "before it was described" because

[Python-ideas] Re: Universal parsing library in the stdlib to alleviate security issues

2019-07-18 Thread Barry Scott
> On 18 Jul 2019, at 05:23, Nam Nguyen wrote: > > On Wed, Jul 17, 2019 at 12:38 AM Barry Scott <mailto:ba...@barrys-emacs.org>> wrote: >> But if your use cases call for performance, it is perfectly fine to >> understand the tradeoffs, and opt in to

[Python-ideas] Re: Universal parsing library in the stdlib to alleviate security issues

2019-07-17 Thread Barry Scott
> On 17 Jul 2019, at 05:17, Nam Nguyen wrote: > > On Tue, Jul 16, 2019 at 1:18 PM Barry > wrote: > > > > On 16 Jul 2019, at 04:47, Andrew Barnert via Python-ideas > > mailto:python-ideas@python.org>> wrote: > > > > How often do you need to parse a million

[Python-ideas] Re: Implement POSIX ln via shutil.link and shutil.symlink

2019-06-30 Thread Barry Scott
> On 29 Jun 2019, at 15:08, Tom Hale wrote: > > Based on the below positive feedback, I've created a PR here: > > https://github.com/python/cpython/pull/14464 > > Only shutil.symlink is currently implemented. Feedback (and possibly fixes) > requested from Windows users. > > Thanks to all

[Python-ideas] Re: Argumenting in favor of first()

2019-12-09 Thread Barry Scott
> On 9 Dec 2019, at 20:07, Wes Turner wrote: > > class TooShortValueError(ValueError): > class TooLongValueError(ValueError): > I had to think about the short and long for a moment. I'd suggest: class TooManyItems(ValueError): class TooFewItems(ValueError): Barry

[Python-ideas] Re: Where should we put the python-ideas HOWTO?

2019-12-02 Thread Barry Scott
Add a link to the HOWTO into the mailman footer? Barry > On 1 Dec 2019, at 15:45, C. Titus Brown wrote: > > Hi folks, > > sorry, took me more than a few months, but I wrote a draft of a python-ideas > HOWTO here, > > https://hackmd.io/@-6xkuCDkTrSFptQEimAdcg/B1noEGh2H > > Thanks to Eric

[Python-ideas] Re: Annotated string literals

2020-02-04 Thread Barry Scott
> On 3 Feb 2020, at 01:28, Soni L. wrote: > > It'd be cool to attach metadata to string literals that doesn't end up in the > resulting string object. This metadata could be used by all sorts of tools, > everything from localization to refactoring. > > In C, some localization libraries use

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Barry Scott
> On 16 Feb 2020, at 09:38, ananthakrishnan15.2...@gmail.com wrote: > > This module should contain operations that can be performed on binary numbers. > In the below examples a and b are binary numbers. Assuming you mean that a "binary number" is int then python can do what you want I think.

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread Barry Scott
> On 16 Feb 2020, at 17:49, ananthan ananthan > wrote: > > But there is a problem with (0b1101). > > 5==0b101 > -5==-0b101 > > but we want output -5==1011. > so this is not possible by using integers with base designator "0b". There is no such thing as an 'integers with base designator

[Python-ideas] Re: Improve SyntaxError for obvious issue:

2020-01-15 Thread Barry Scott
> On 14 Jan 2020, at 18:42, Guido van Rossum wrote: > > On the subject of replacing the current parser, I am actively working on > that. See GitHub.com/gvanrossum/pegen. Will that allow me to write this? if a > 3 and x < 6: doit() Barry > > On Tue, Jan 14, 2020 at 10:32 Andrew

[Python-ideas] Re: Enhancing Zipapp

2020-01-08 Thread Barry Scott
> On 8 Jan 2020, at 16:02, Christopher Barker wrote: > > On Wed, Jan 8, 2020 at 1:49 AM Abdur-Rahmaan Janhangeer > wrote: > Have a look at this write up about the horror that is zip file name handling. > >

[Python-ideas] Re: Add a PyObject_VaCallFunction to C API??

2020-01-06 Thread Barry Scott
> On 5 Jan 2020, at 22:20, hrfu...@gmail.com wrote: > > The C API has a function PyObject_CallFunction( PyObject*, const char* fmt, > ... ). It is a variadic function hence I couldn't pass a va_list to it to > invoke the call. My question is, is it technically possible to provide a >

[Python-ideas] Re: Enhancing Zipapp

2020-01-06 Thread Barry Scott
> On 6 Jan 2020, at 19:34, Abdur-Rahmaan Janhangeer > wrote: > > Note: draft simplified Please cover the pro's and con's of the alernatives that have been raised as comments on this idea, as is usually done for a PEP style document. Also beware that zip file format does not include the

[Python-ideas] Re: prefix/suffix for bytes

2020-03-11 Thread Barry Scott
> On 11 Mar 2020, at 19:03, Rhodri James wrote: > > On 11/03/2020 18:45, Stephen J. Turnbull wrote: >> Rhodri James writes: >> > We've headed off down the rabbit-hole of filenames for >> > justification here, but surely pathlib is the correct tool if you >> > are going to be chopping up

[Python-ideas] Re: Improve the Windows python installer to reduce new user confusion

2020-04-11 Thread Barry Scott
> On 10 Apr 2020, at 20:14, Christopher Barker wrote: > > I rarely use Windows, but do support them, so this sounds good to me. > > But one confusion: > > With py.exe no need to mess with the PATH. > > How does py.exe get on the PATH? > > Now that the need for python 2 and 3 on the same

[Python-ideas] Improve the Windows python installer to reduce new user confusion

2020-04-10 Thread Barry Scott
The Python Users list most often asked question seems to be from Windows users who run the installed multiple times because they assume that the install is the python program. Followed by I installed Python, where is it? My suggestion is that the installer wizard "Setup was successful" panel has

[Python-ideas] Re: About python3 on windows

2020-03-26 Thread Barry Scott
> On 25 Mar 2020, at 16:53, Paul Moore wrote: > > On Wed, 25 Mar 2020 at 16:10, Eryk Sun wrote: > >> The py launcher's "env" command searches PATH for anything from >> "python" to "notepad" -- but not for a versioned Python command such >> as "python3" or "python2". It always uses a

[Python-ideas] Re: About python3 on windows

2020-03-26 Thread Barry Scott
> On 25 Mar 2020, at 17:02, Andrew Barnert wrote: > > On Mar 25, 2020, at 05:02, Paul Moore wrote: >> >> The only reason anyone has ever suggested versioned executables on >> Windows is for Unix compatibility - the reasons they are needed on >> Unix simply don't apply on Windows (at least

[Python-ideas] Re: About python3 on windows

2020-03-25 Thread Barry Scott
> On 25 Mar 2020, at 09:15, Eryk Sun wrote: > > On 3/25/20, Steve Barnes wrote: >>> Except it's not necessarily what the original post wants. The OP wants the >>> shebang "#!/usr/bin/env python3" to "work everywhere by >>> default", for which I assume it's implied that it should work

[Python-ideas] Re: zip(x, y, z, strict=True)

2020-04-29 Thread Barry Scott
> On 28 Apr 2020, at 16:12, Rhodri James wrote: > > On 28/04/2020 15:46, Brandt Bucher wrote: >> Thanks for weighing in, everybody. >> Over the course of the last week, it has become surprisingly clear that this >> change is controversial enough to require a PEP. >> With that in mind, I've

[Python-ideas] Re: deque: Allow efficient operations

2020-04-29 Thread Barry Scott
> On 29 Apr 2020, at 12:36, remi.lape...@henki.fr wrote: > > Also, removing an element from a doubly-linked list is not a O(1) operation, > it's O(n). It's O(1) once you have a pointer to the element but you have to > iterate over the list to get it and that would take O(n) operations, so >

[Python-ideas] Re: Adding a "once" function to functools

2020-04-28 Thread Barry Scott
> On 28 Apr 2020, at 02:04, Steven D'Aprano wrote: > > Yes, it's annoying when English words can have two or more meanings. The > first time I can across math.sin, I was very excited, until I realised > it was just the trigonometric function :-( @once def my_func(): ... I read

[Python-ideas] Re: Sanitize filename (path part) 2nd try

2020-05-11 Thread Barry Scott
> On 11 May 2020, at 18:09, Andrew Barnert via Python-ideas > wrote: > > More generally, what’s the use case for %-encoding filenames like this? Are > people expecting it to interact transparently with URLs, so if I save a file > “spam\0eggs” in a Python script and then try to browse to

[Python-ideas] Re: Sanitize filename (path part)

2020-05-11 Thread Barry Scott
> On 10 May 2020, at 01:34, Steve Jorgensen wrote: > > I believe the Python standard library should include a means of sanitizing a > filesystem entry, and this should not be something requiring a 3rd party > package. snip I found that I needed to have code that could tell me if a

[Python-ideas] Re: Sanitize filename (path part)

2020-05-12 Thread Barry Scott
> On 11 May 2020, at 23:24, Andrew Barnert wrote: > > On May 11, 2020, at 13:31, Barry Scott wrote: >> >> macOS and Unix version (I only use Unicode input so avoid the random bytes >> problems): > > But that doesn’t avoid the problem. If someone gives

[Python-ideas] Re: Sanitize filename (path part) 2nd try

2020-05-12 Thread Barry Scott
> On 11 May 2020, at 22:38, Andrew Barnert wrote: > > On May 11, 2020, at 12:59, Barry Scott wrote: >> >> >>> On 11 May 2020, at 18:09, Andrew Barnert via Python-ideas >>> mailto:python-ideas@python.org>> wrote: >>> >>> Mo

  1   2   >