Re: [Python-ideas] Assign-in-place operator

2019-06-04 Thread Terry Reedy
On 6/4/2019 6:47 AM, Jeroen Demeyer wrote: I'd like to get rid of all the signal and HDL stuff (whatever that means) in this thread, so I think what the original poster really wants is an "assign in place" operator. Basically, something like += or *= but without the arithmetic. I believe

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

2019-05-25 Thread Terry Reedy
On 5/25/2019 3:09 PM, Yanghao Hua wrote: @= has all the same issues like <<= or >>=, No, it does not in that you are basically sacrificing a well known number operation because @= is not a number operation at all. I admit this (@=) is a much rarer case, It is a different case. but

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

2019-05-25 Thread Terry Reedy
On 5/24/2019 4:25 PM, Yanghao Hua wrote: On Fri, May 24, 2019 at 5:45 PM Terry Reedy wrote: What I understand is that you are doing discrete-time hardware simulation and that you need a operator that will schedule future assigments to int-like objects. Have you considered using '@' to do

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

2019-05-24 Thread Terry Reedy
On 5/24/2019 8:50 AM, Yanghao Hua wrote: for instance, I explained already but here again: you will need to have "this_signal <<= (that_signal << 4) + something, and next line you should be able to write this_signal <<= 4 bit, where all arithmetic operation still have to be kept. Otherwise it

Re: [Python-ideas] Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-05-19 Thread Terry Reedy
On 5/19/2019 3:00 PM, Chris Angelico wrote: On Mon, May 20, 2019 at 4:46 AM Terry Reedy wrote: On 5/18/2019 10:01 PM, Chris Angelico wrote: 2) Redefine the 'with' block or create a new syntactic form such that the variable actually creates a subscope. That way, at the end of the block

Re: [Python-ideas] Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-05-19 Thread Terry Reedy
On 5/18/2019 10:01 PM, Chris Angelico wrote: 2) Redefine the 'with' block or create a new syntactic form such that the variable actually creates a subscope. That way, at the end of the block, the name would revert to its former meaning. x = 1 with local 2 as x: print(x) # 2 print(x) # 1

Re: [Python-ideas] Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-05-19 Thread Terry Reedy
On 5/18/2019 10:44 PM, Yonatan Zunger wrote: Terry, let me make sure I'm understanding your responses. (1) Only certain things should be CM's, and those things should be explicitly denoted as such. Thinking about the first one, the purpose of the context manager protocol is to allow

Re: [Python-ideas] Proposal: Allowing any variable to be used in a 'with... as...' expression

2019-05-18 Thread Terry Reedy
On 5/18/2019 8:13 PM, Yonatan Zunger wrote: Hi everyone, I'd like to bounce this proposal off everyone and see if it's worth formulating as a PEP. I haven't found any prior discussion of it, but as we all know, searches can easily miss things, so if this is old hat please LMK. *Summary:

Re: [Python-ideas] Passing positional arguments as keyword arguments (to provide function arguments out of order)

2019-05-16 Thread Terry Reedy
On 5/16/2019 8:23 AM, Anders Hovmöller wrote: On 16 May 2019, at 08:50, Serhiy Storchaka wrote: Writing the code that parses args is errorprone and inefficient. There are also other rationales of PEP 570. I've read it. It is unconvincing to me. That's fine. Coredevs don't always agree

Re: [Python-ideas] Break multiple loop levels

2019-05-11 Thread Terry Reedy
On 5/11/2019 1:20 PM, haael wrote: Python allows for breaking out from a loop through 'break' and 'continue' keywords. It would be nice if it was possible to break many loop levels using one command. I propose two constructions for that: break break break break break break ... continue

Re: [Python-ideas] What are the strong use cases for str.rindex()?

2019-04-25 Thread Terry Reedy
On 4/25/2019 7:12 PM, Greg Ewing wrote: Steven D'Aprano wrote: I too often forget that reverse() returns an iterator, I presume you mean reversed(). list.reverse() is a list That seems like a mistake. Shouldn't it return a view? RL = reversed(somelist) is already partly view-like. The

Re: [Python-ideas] contains_any_in and contains_all_in

2019-04-23 Thread Terry Reedy
On 4/23/2019 4:39 PM, João Matos wrote: Hello, If we want to check if a string contains any/all of several other strings we have to use several or/and conditions or any/all. For any: |if ('string1' in master_string or 'string2' in master_string     or 'string3' in master_string): or

Re: [Python-ideas] What are the strong use cases for str.rindex()?

2019-04-23 Thread Terry Reedy
On 4/23/2019 2:44 AM, 林自均 wrote: Hi all, I found that there are str.index() and str.rindex(), but there is only list.index() and no list.rindex(). str.index and list.index are related but not the same. The consistency argument is better applied to find-rfind, index-rindex,

Re: [Python-ideas] Catching the return value of a generator at the end of a for loop

2019-04-16 Thread Terry Reedy
On 4/16/2019 4:54 PM, Stefano Borini wrote: given the following code def g(): yield 2 yield 3 return 6 for x in g(): print(x) The output is obviously 2 3 As far as I know, there is currently no way to capture the StopIteration value when the generator is used in a for

Re: [Python-ideas] Logical tracebacks

2019-04-15 Thread Terry Reedy
On 4/15/2019 4:07 PM, Antoine Pitrou wrote: Hello, I apologize because I'm only going to throw a very vague idea and I don't currently have time or motivation to explore it myself. But I think it may prove interesting for other people and perhaps spur some concrete actionable proposal. With

Re: [Python-ideas] Sorted lists

2019-04-08 Thread Terry Reedy
On 4/8/2019 4:48 PM, Barry Scott wrote: 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

Re: [Python-ideas] Sorted lists

2019-04-08 Thread Terry Reedy
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 used in a lot of existing list contexts), but only exposed

Re: [Python-ideas] Sorted lists

2019-04-07 Thread Terry Reedy
On 4/7/2019 10:32 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. Sorting a list is potentially expensive: while Timsort is very efficient, it is still

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

2019-04-01 Thread Terry Reedy
On 4/1/2019 1:14 AM, Guido van Rossum wrote: We do have a parser generator in the standard library: https://github.com/python/cpython/tree/master/Lib/lib2to3/pgen2 It is effectively undocumented and by inference discouraged from use. The entry for lib2to3 in the 2to3 doc:

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

2019-03-25 Thread Terry Reedy
On 3/25/2019 10:55 AM, David Mertz wrote: All of this would be well served by a 3rd party library on PyPI. Strings already have plenty of methods (probably too many).  Having `stringtools` would be nice to import a bunch of simple functions from. I agree. -- Terry Jan Reedy

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

2019-03-25 Thread Terry Reedy
On 3/25/2019 6:22 AM, Jonathan Fine wrote: Instead of naming these operations, we could use '+' and '-', with semantics:     # Set the values of the variables.     >>> a = 'hello '     >>> b = 'world'     >>> c = 'hello world'     # Some values between the variables.     >>> a + b == c

Re: [Python-ideas] Why not ['a','b','c'].join(',') ?

2019-03-23 Thread Terry Reedy
On 3/23/2019 7:35 PM, Juancarlo Añez wrote: I know it has been discussed endlessly, So please read any of the endless discussions either on this list or python-list. I myself have answered multiple times. -- Terry Jan Reedy ___ Python-ideas

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

2019-03-22 Thread Terry Reedy
On 3/22/2019 12:53 AM, Steven D'Aprano wrote: On Thu, Mar 21, 2019 at 09:36:20PM -0400, Terry Reedy wrote: I counted what I believe to be 10 instances of copy-update in the top level of /lib. Do either of you consider this to be enough that any addition would be worthwhile. I think you're

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

2019-03-21 Thread Terry Reedy
On 3/21/2019 12:11 PM, Guido van Rossum wrote: On Thu, Mar 21, 2019 at 7:45 AM Antoine Pitrou One should also be able to write `d = dict.merge(d1, d2, ...)` If dict merging is important enough to get a new spelling, then I think this proposal is the best: explicit, unambiguous,

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Terry Reedy
On 3/16/2019 8:01 AM, Gustavo Carneiro wrote: On Sat, 16 Mar 2019 at 10:33, Steven D'Aprano > wrote: The question this PEP is trying to answer is not "can we support every use-case imaginable for a merge operator?" but "can we support the most typical

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Terry Reedy
I agree with Guido's general comments on operators. Modern arithmetic and algebra really took off with the introduction of operators. On the other hand, I have seen condensed blocks of 'higher math', dense with operators, that I could hardly read, and that reminded me of API or Perl. On

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-15 Thread Terry Reedy
happened. https://mail.python.org/pipermail/python-ideas/2009-April/003897.html You proposed that in April 2009, but there was nothing added to the bug tracker for 18 months until it was finally added by Terry Reedy in Actually, I opened the tracker issue with a succinct message, after the discussion

Re: [Python-ideas] Make Python 2.7’s online docs optionally redirect to Python 3 online docs

2019-03-07 Thread Terry Reedy
On 3/7/2019 8:56 AM, Steven D'Aprano wrote: On Thu, Mar 07, 2019 at 08:10:20AM -0500, James Lu wrote: Rationale: When I use a search engine to google a Python question, I frequently get a link to a page of the Python 2.7 documentation that shows before the Python 3 documentation link. This is

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

2019-03-06 Thread Terry Reedy
On 3/6/2019 3:12 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. I am not familiar with setup.py, so I don't know how this affects the

Re: [Python-ideas] PEP 8 update on line length

2019-02-18 Thread Terry Reedy
On 2/18/2019 11:37 PM, Simon wrote: Hello, I'd like to propose an update to PEP8. Indeed, the 80 characters per line guideline is, I feel, outdated. Strictly speaking, PEP8 applies only to CPython stdlib code. Please read the introduction. Adapt it as you will for your code. I

Re: [Python-ideas] Clearer communication

2019-02-03 Thread Terry Reedy
On 2/2/2019 10:59 AM, James Lu wrote: I think we need to ... have some way of knowing that Python committees are python committers. It’s really difficult to know how well your proposal is doing without having this. That has occurred to me also. If two or three core developers respond

Re: [Python-ideas] What factors led Guido to quit?

2019-02-03 Thread Terry Reedy
On 2/2/2019 11:04 AM, James Lu wrote: What factors led Guido to quit? Guido resigned as 'Enhancement Czar'. He wrote what he want to say publicly as to why in his message to the committers list. Speculating beyond that strikes me as rude. He did not resign as President of the PSF nor as

Re: [Python-ideas] Option of running shell/console commands inside the REPL

2019-02-02 Thread Terry Reedy
On 2/2/2019 8:13 AM, Oleg Broytman wrote: On Fri, Feb 01, 2019 at 08:40:22PM -0500, Terry Reedy wrote: On 2/1/2019 3:31 PM, Oleg Broytman wrote: Python REPL is missing the following batteries: That is why, on Windows, I nearly always use IDLE. I believe this was Chris, not me

Re: [Python-ideas] Option of running shell/console commands inside the REPL

2019-02-01 Thread Terry Reedy
On 2/1/2019 3:31 PM, Oleg Broytman wrote: Python REPL is missing the following batteries: That is why, on Windows, I nearly always use IDLE. * Persistent history; IDLE's Shell history persists across restarts (which are not available is the standard shell). I cannot remember wanting

Re: [Python-ideas] How do ideas on this mailing list turn into features?

2019-02-01 Thread Terry Reedy
On 2/1/2019 1:10 PM, James Lu wrote: How do ideas on this mailing list turn into features? What is the typical roadmap? Can this process be documented somewhere? Ultimately, one or more people write Pull Request, usually containing new tests, that passes all tests. Then a Core Developer with

Re: [Python-ideas] Option of running shell/console commands inside the REPL

2019-02-01 Thread Terry Reedy
On 2/1/2019 9:24 AM, Ken Hilton wrote: Hi, As a workaround/alternative, you can just do     >>> import os     >>> os.system('dir') For repeated use within and between sessions, put 'from os import system as oss' in a startup file. Then one only needs "oss('dir')". Note that 'dir' only

Re: [Python-ideas] Option of running shell/console commands inside the REPL

2019-02-01 Thread Terry Reedy
On 2/1/2019 1:50 PM, James Lu wrote: It’s difficult to learn anything with a body (such as a loop or a class or a function) with the built in REPL because you can’t edit lines you’ve already written. I presume you mean that it is 'difficult to learn about compound statements and multiline

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

2019-01-31 Thread Terry Reedy
On 1/31/2019 12:51 PM, Chris Barker via Python-ideas wrote: I do a lot of numerical programming, and used to use MATLAB and now numpy a lot. So I am very used to "vectorization" -- i.e. having operations that work on a whole collection of items at once. Example: a_numpy_array * 5

Re: [Python-ideas] AMEND PEP-8 TO DISCOURAGE ALL CAPS

2019-01-30 Thread Terry Reedy
On 1/30/2019 6:41 PM, Abe Dillon wrote: I think continued discussion is pretty useless. 1. Most everything relevant has been said, likely more than once, and 2. The required core-developer support does not exist. PEP 8 was written by Guido with input from other core developers. As Chris

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

2019-01-29 Thread Terry Reedy
On 1/29/2019 7:12 PM, MRAB wrote: On 2019-01-29 23:30, Terry Reedy wrote: On 1/28/2019 8:40 PM, Jamesie Pic wrote:   > 0. os.path.join takes *args Since at least 1 path is required, the signature is join(path, *paths). I presume that this is the Python version of the Unix vers

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

2019-01-16 Thread Terry Reedy
On 1/16/2019 7:26 PM, Abdur-Rahmaan Janhangeer wrote: let us say i'm a novice user, for me py's gui is such. if on Mac it gives rounded corners but on others no, it's pretty unpredictable. and if it does have roundedness but you can't control it then it's no good It is using native widgits of

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

2019-01-16 Thread Terry Reedy
On 1/16/2019 11:11 AM, Abdur-Rahmaan Janhangeer wrote: without starting a should we ban tkinter discussion, Then don't bring up such an idea. i'd like to propose that we add rounded corners buttons. This is out-of-scope for python-ideas. 'Tkinter' abbreviates 'Tk interface'. It provides

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-11 Thread Terry Reedy
On 12/11/2018 6:50 PM, Greg Ewing wrote: I'm not necessarily saying this *should* be done, just pointing out that it's a possible strategy for migrating map() from an iterator to a view, if we want to do that. Python has list and list_iterator, tuple and tuple_iterator, set and set_iterator,

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-11 Thread Terry Reedy
On 12/11/2018 12:01 PM, Chris Barker - NOAA Federal via Python-ideas wrote: Perhaps I got confused by the early part of this discussion. My point was that there is no “map-like” object at the Python level. (That is no Map abc). Py2’s map produced a sequence. Py3’s map produced an iterable. So

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-11 Thread Terry Reedy
On 12/11/2018 6:48 AM, E. Madison Bray wrote: The idea would be to now enhance the existing built-ins to restore at least some previously lost assumptions, at least in the relevant cases. To give an analogy, Python 3.0 replaced range() with (effectively) xrange(). This broken a lot of

Re: [Python-ideas] __len__() for map()

2018-12-11 Thread Terry Reedy
On 12/1/2018 2:08 PM, Steven D'Aprano wrote: This proof of concept wrapper class could have been written any time since Python 1.5 or earlier: class lazymap: def __init__(self, function, sequence): One could now add at the top of the file from collections.abc import Sequence and

Re: [Python-ideas] Suggested MapView object (Re: __len__() for map())

2018-12-11 Thread Terry Reedy
On 12/1/2018 8:07 PM, Greg Ewing wrote: Steven D'Aprano wrote: After defining a separate iterable mapview sequence class For backwards compatibilty reasons, we can't just make map() work like this, because that's a change in behaviour. Actually, I think it's possible to get the best of

Re: [Python-ideas] __len__() for map()

2018-11-29 Thread Terry Reedy
On 11/29/2018 8:16 AM, E. Madison Bray wrote: Okay, let's keep it simple: m = map(str, [1, 2, 3]) len_of_m = None if len(m.iters) == 1 and isinstance(m.iters[0], Sized): len_of_m = len(m.iters[0]) As I have noted before, the existing sized collection __length_hint__ methods (properly)

Re: [Python-ideas] __len__() for map()

2018-11-29 Thread Terry Reedy
On 11/29/2018 6:13 AM, E. Madison Bray wrote: On Wed, Nov 28, 2018 at 8:54 PM Terry Reedy wrote: The CPython map() implementation already carries this data on it as "func" and "iters" members in its struct. It's trivial to expose those to Python as ".funcs" and

Re: [Python-ideas] __len__() for map()

2018-11-29 Thread Terry Reedy
On 11/28/2018 5:27 PM, Steven D'Aprano wrote: On Wed, Nov 28, 2018 at 02:53:50PM -0500, Terry Reedy wrote: One of the guidelines in the Zen of Python is "Special cases aren't special enough to break the rules." This proposal claims that the Python 3 built-in iterator class 'map' is

Re: [Python-ideas] __len__() for map()

2018-11-28 Thread Terry Reedy
On 11/28/2018 9:27 AM, E. Madison Bray wrote: On Mon, Nov 26, 2018 at 10:35 PM Kale Kundert wrote: I just ran into the following behavior, and found it surprising: len(map(float, [1,2,3])) TypeError: object of type 'map' has no len() I understand that map() could be given an infinite

Re: [Python-ideas] __len__() for map()

2018-11-27 Thread Terry Reedy
On 11/26/2018 4:29 PM, Kale Kundert wrote: I just ran into the following behavior, and found it surprising: >>> len(map(float, [1,2,3])) TypeError: object of type 'map' has no len() I understand that map() could be given an infinite sequence and therefore might not always have a length.

Re: [Python-ideas] Decide if `type.__subclasses__` is part of future Python or not

2018-10-29 Thread Terry Reedy
On 10/29/2018 2:25 PM, Joy Diamond wrote: Thanks, Storchaka for finding the documentation. Though it is really annoying I could not find it with a google search... Next time, start with our excellent index, which includes a page for words starting with '_'. There is another page for

Re: [Python-ideas] Fix documentation for __instancecheck__

2018-10-27 Thread Terry Reedy
On 10/27/2018 2:53 PM, Joy Diamond wrote: Chris, Yes, the following works: """ (Note that any object `x` is always considered to be an instance of `type(x)`, and this cannot be overridden.) """ Open a doc issue on bugs.python.org with the problem, motivation, and proposed solution and it

Re: [Python-ideas] Multi Statement Lambdas

2018-10-21 Thread Terry Reedy
On 10/21/2018 12:28 PM, Andreas Winschu wrote A def function has to be named. In general, this is a good thing. It often improves tracebacks. Perhaps more importantly, name facilitate testing and mocking. Wheres a lambda expression can be passed anonymously to any other function as an

Re: [Python-ideas] Python Enhancement Proposal for List methods

2018-10-21 Thread Terry Reedy
On 10/21/2018 9:00 AM, Siva Sukumar Reddy wrote: I am really new to Python contribution community want to propose below methods for List object. For most classes, there is an infinite number of possible functions that could be made into methods. The Python philosophy is to include as

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

2018-10-08 Thread Terry Reedy
On 10/8/2018 10:26 AM, Steven D'Aprano wrote: On Sun, Oct 07, 2018 at 04:24:58PM -0400, Terry Reedy wrote: https://www.win.tue.nl/~wstomv/edu/2ip30/references/design-by-contract/index.html defines contracts as "precise (legally unambiguous) specifications" (5.2 Business Contr

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

2018-10-07 Thread Terry Reedy
On 10/7/2018 12:32 AM, Ram Rachum wrote: Does that mean I'll have to write that character-by-character algorithm? I would not be surprised if you could make use of str.index, which scans at C speed. See my answer to Nathaniel. -- Terry Jan Reedy

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

2018-10-07 Thread Terry Reedy
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 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

Re: [Python-ideas] Better error messages for missing optional stdlib packages

2018-10-07 Thread Terry Reedy
On 10/3/2018 4:29 PM, Marcus Harnisch wrote: When trying to import lzma on one of my machines, I was suprised to get a normal import error like for any other module. What was the traceback and message? Did you get an import error for one of the three imports in lzma.py. I don't know why you

Re: [Python-ideas] Simplicity of C (was why is design-by-contracts not widely)

2018-10-07 Thread Terry Reedy
On 9/30/2018 2:19 AM, Marko Ristin-Kaufmann wrote: The library name will also need to change. When I started developing it, I was not aware of Java icontract library. It will be probably renamed to "pcontract" or any other suggested better name :) 'icontract' immediatly looks to me like

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

2018-10-07 Thread Terry Reedy
On 9/24/2018 3:46 AM, Marko Ristin-Kaufmann wrote: I am responding to your request "Please do point me to what is not obvious to you". I think some of your claims are not only not obvious, but are wrong. I have read some (probably less than half) of the responses and avoid saying what I

Re: [Python-ideas] Moving to another forum system where

2018-09-20 Thread Terry Reedy
On 9/20/2018 3:38 AM, Hans Polak wrote: I don’t think its unreasonable to point out that the title of this thread is "Moving to another forum". If you want to contribute Python Ideas you *have to* subscribe to the mailing list. Or you can point your mail/news reader to news.gmane.org and

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

2018-09-13 Thread Terry Reedy
On 9/13/2018 7:34 PM, Tim Peters wrote: I already made clear that I'm opposed to changing it.\ To me, this settles the issues. As author, you own the copyright on your work. The CLA allows revision of contributions, but I don't think that contributed poetry should be treated the same as

Re: [Python-ideas] Improving fn(arg=arg, name=name, wibble=wibble) code

2018-09-08 Thread Terry Reedy
On 9/8/2018 7:17 AM, Jonathan Fine wrote: I thank Steve D'Aprano for pointing me to this real-life (although perhaps extreme) code example https://github.com/Tinche/aiofiles/blob/master/aiofiles/threadpool/__init__.py#L17-L37 def open(file, mode='r', buffering=-1, encoding=None, errors=None,

Re: [Python-ideas] Add Unicode-aware str.reverse() function?

2018-09-08 Thread Terry Reedy
On 9/8/2018 7:33 AM, Paddy3118 wrote: I wrote a blog post nearly a decade ago on extending a Rosetta Code task example to handle the correct reversal of strings with

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

2018-08-24 Thread Terry Reedy
On 8/24/2018 4:12 AM, Wes Turner wrote: There was a thread about deprecating Tk awhile back. That was an intentionally annoying troll post, not a serious proposal. Please don't refer to it as if it were. asyncio event loop support would be great for real world apps. This is unclear.

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

2018-08-20 Thread Terry Reedy
On 8/20/2018 5:13 PM, Barry Scott wrote: 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

Re: [Python-ideas] Asynchronous friendly iterables

2018-08-20 Thread Terry Reedy
On 8/20/2018 3: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? One purpose of

Re: [Python-ideas] With expressions

2018-08-02 Thread Terry Reedy
On 8/2/2018 7:53 AM, Thomas Nyberg via Python-ideas wrote: On 08/02/2018 12:43 PM, Paul Moore wrote: But if someone wanted to raise a doc bug suggesting that we mention this, I'm not going to bother objecting... Paul I opened a bug here: https://bugs.python.org/issue34319 We can see

Re: [Python-ideas] Idea: msgfmt.py and pygettext..py should be -m executable modules

2018-07-30 Thread Terry Reedy
On 7/30/2018 9:43 AM, Petr Viktorin wrote: On Mon, Jul 23, 2018 at 2:16 PM, Miro Hrončok wrote: $ python3 -m gettext.msgfmt +1 Note that this means gettext will need to become a package. Once there is a command line interface, arguments can be supplied to the module, as in python -m

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Terry Reedy
On 7/26/2018 1:23 PM, Terry Reedy wrote: On 7/26/2018 1:21 PM, Terry Reedy wrote: On python-idea,  Miro Hrončok asked today whether we can change the OrderedDict repr from, for instance, OrderedDict([('a', '1'), ('b', '2')]) # to OrderedDict({'a': '1', 'b': '2'}) I am not sure what our repr

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-26 Thread Terry Reedy
On 7/26/2018 1:21 PM, Terry Reedy wrote: On python-idea,  Miro Hrončok asked today whether we can change the OrderedDict repr from, for instance, OrderedDict([('a', '1'), ('b', '2')]) # to OrderedDict({'a': '1', 'b': '2'}) I am not sure what our repr change policy is, as there is a back

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

2018-07-20 Thread Terry Reedy
On 7/20/2018 12:21 AM, Nathaniel Smith wrote: 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

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Terry Reedy
On 7/19/2018 8:30 AM, Jonathan Fine wrote: Hi There is a formatted version of this PEP at https://www.python.org/dev/peps/pep-0505/ I've taken a look at this, and have some comments on the first two examples drawn from standard library code. (And a very grateful +10 for writing a script to

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Terry Reedy
On 7/19/2018 4:33 AM, Antoine Pitrou wrote: This is adding a whole range of new operators without enough of a use case. It is also making code harder to read, as evaluation can stop at any of the "?*" operators. And it looks like noise (or like Perl 6, which is the same). There is a use case

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Terry Reedy
On 7/19/2018 4:32 AM, Stephen J. Turnbull wrote: Chris Angelico writes later in thread: > On Thu, Jul 19, 2018 at 9:55 AM, Giampaolo Rodola' wrote: > Personally, I'm +0 on this. It'd be a few small wins here and there, > nothing huge, and I could easily live without it; but it's

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

2018-07-14 Thread Terry Reedy
On 7/14/2018 5:40 AM, Antoine Pitrou wrote: On Fri, 13 Jul 2018 18:22:24 -0600 Eric Snow wrote: 2. Give up on making things work inside the same OS process and rather focus on implementing better abstractions on top of the existing multiprocessing API so that the actor model is easier to

Re: [Python-ideas] Support localization of unicode descriptions

2018-07-10 Thread Terry Reedy
e cpython repository. On Tue, Jul 10, 2018, 5:11 PM Terry Reedy <mailto:tjre...@udel.edu>> wrote: On 7/10/2018 4:45 AM, Pander wrote: > This is a third party initiative. The translations are contributed by > volunteers. I have talked with Python core developers an

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

2018-07-10 Thread Terry Reedy
On 7/10/2018 10:31 AM, David Foster wrote: Since you're speaking in the past tense and said "but we're not doing it like that", I infer that the notion of a parallel thread was turned down for integration into CPython, as that appears to have been the original goal. A far as I remember,

Re: [Python-ideas] Support localization of unicode descriptions

2018-07-10 Thread Terry Reedy
On 7/10/2018 4:45 AM, Pander wrote: This is a third party initiative. The translations are contributed by volunteers. I have talked with Python core developers and they suggested to post this here, as it is for them out of scope for Python std lib. Python-ideas list is for discussion of

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

2018-06-23 Thread Terry Reedy
On 6/23/2018 8:14 PM, Greg Ewing wrote: Paul Moore wrote: a = SafeStr("my secret data") ... work with a as if it were a string del a But in order to create the SafeStr, you need to first have the data in the form of an ordinary non-safe string. How do you dispose of that safely? getpass

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

2018-06-22 Thread Terry Reedy
On 6/22/2018 8:45 PM, Chris Angelico wrote: Would it suffice to flag the string as "this contains sensitive data, please overwrite its buffer when it gets deallocated"? The only difference, in your example, would be that the last print would show the original data, and the wipe would happen

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

2018-06-22 Thread Terry Reedy
On 6/22/2018 8:31 PM, Ezequiel Brizuela [aka EHB or qlixed] wrote: As all the string in python are immutable, is impossible to overwrite the value Not if one uses ctypes. Is that what you did?   Well I already do it: https://github.com/qlixed/python-memwiper/ But i hit a lot of

Re: [Python-ideas] String and bytes bitwise operations

2018-06-22 Thread Terry Reedy
On 6/22/2018 7:08 AM, INADA Naoki wrote: Bitwise xor is used for "masking" code like these: https://github.com/PyMySQL/PyMySQL/blob/37eba60439039eff17b32ef1a63b45c25ea28cec/pymysql/connections.py#L139-L146 This points to a function _my_crypt that is O(n*n) because of using bytes.append.

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Terry Reedy
On 6/15/2018 8:42 PM, Greg Ewing wrote: Mikhail V wrote: It s just very uncommon to see standalone statements like: x.method() for me it came into habit to think that it lacks the left-hand part and =. You must be looking at a very limited and non-typical corpus of Python code. Mutating

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-12 Thread Terry Reedy
On 6/12/2018 10:54 AM, Mikhail V wrote: I think it would be logical to have the insert operator for lists. Similar to list extend operator += , it could use one of augmented assignment operators, e,g, /=. ... Note that there is a trick to 'insert' an element with slicing syntax, e.g.: This

Re: [Python-ideas] Trigonometry in degrees

2018-06-10 Thread Terry Reedy
On 6/10/2018 10:44 AM, Stephan Houben wrote: I would suggest that compatibility with a major Python library such as SciPy is more important than compatibility with other programming languages. I would go even further and argue that scipy.special.sindg and its friends cosdg and tandg can

Re: [Python-ideas] A "within" keyword

2018-06-08 Thread Terry Reedy
On 6/8/2018 6:07 PM, Michael Selik wrote: You can use ``eval`` to run an expression, swapping in a different globals and/or locals namespace. Will this serve your purpose? In [1]: import types In [2]: ns = types.SimpleNamespace(a=1) In [3]: eval('a', ns.__dict__) Out[3]: 1

Re: [Python-ideas] Let try-except check the exception instance

2018-05-31 Thread Terry Reedy
On 5/31/2018 12:47 AM, Danilo J. S. Bellini wrote: Hi! I was working on handling some exceptions from external software (e.g. database constraint triggers) switching the handler based on the messages that had been sent. Today we can do something like (running on Python 3.6.5): try: ...     #

Re: [Python-ideas] Was `os.errno` undocumented?

2018-05-29 Thread Terry Reedy
On 5/29/2018 6:06 AM, Petr Viktorin wrote: Python 3.7 removes the undocumented internal import `os.errno`. Among a couple of hundred others, including some from idlelib. We consider that a an implementation detail, which can be changed *without notice* even in a bugfix release. We core

Re: [Python-ideas] Was `os.errno` undocumented?

2018-05-29 Thread Terry Reedy
On 5/29/2018 12:09 PM, Guido van Rossum wrote: Yes. What Steve says at the end. Let's be kind and mention this one on the release notes. But not all the others. How about adding a general reminder. In Porting to 3.7: "Imports into a module are a private implementation detail unless otherwise

Re: [Python-ideas] "Assignment expression" with function call-alike syntax

2018-05-23 Thread Terry Reedy
On 5/22/2018 5:32 PM, Kirill Balunov wrote: Just one more variation on "assignment exression" syntax to make the list more complete :) Sorry, if something similar has already been suggested. The idea is to use function's call-like syntax in the from: `this( name = expr )`. Functions names

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

2018-05-22 Thread Terry Reedy
On 5/22/2018 5:21 AM, Ken Hilton wrote: Hi all, Just a simple idea I wanted to bring forth. Although I know that you get a lot more asyncio control by importing the asyncio module itself, I'd like to see a way to make simple asynchronous applications without ever importing asyncio itself. To

Re: [Python-ideas] Async Lambda syntax

2018-05-18 Thread Terry Reedy
On 5/18/2018 4: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. Not really. I found this syntax does not currently exist. Obviously I could have (and did) just write a regular coroutine,

Re: [Python-ideas] String and bytes bitwise operations

2018-05-17 Thread Terry Reedy
On 5/17/2018 6:53 AM, Ken Hilton wrote: Hi all, We all know the bitwise operators: & (and), | (or), ^ (xor), and ~ (not). We know how they work with numbers: 420 ^ 502 110100100 10110 == XOR == 001010010 = 82 But it might be useful in some cases to (let's say) xor a string (or

Re: [Python-ideas] Keyword declarations

2018-05-16 Thread Terry Reedy
On 5/16/2018 1:24 PM, Adam Bartoš wrote: Hello, I have yet another idea regarding the the clashes between new keywords and already used names. How about introducing two new keywords *wink* that would serve as lexical keyword/nonkeyword declarations, similarly to nonlocal and global

Re: [Python-ideas] Verbatim names (allowing keywords as names)

2018-05-15 Thread Terry Reedy
On 5/15/2018 8:41 PM, Steven D'Aprano wrote: Inspired by Alex Brault's post: https://mail.python.org/pipermail/python-ideas/2018-May/050750.html I'd like to suggest we copy C#'s idea of verbatim identifiers, but using a backslash rather than @ sign: Not quite as heavy. \name would

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

2018-05-14 Thread Terry Reedy
On 5/14/2018 6:58 PM, Greg Ewing wrote: Terry Reedy wrote: the first two 'and's in "a and b.and # and error" are tagged. To not tag the second would require full parsing, That particular case could be handled by just not colouring any word following a dot. OK, more par

Re: [Python-ideas] Sorry for yet another self discussion

2018-05-14 Thread Terry Reedy
On 5/10/2018 3:58 PM, stefano wrote: I know that "self" parameter have been discussed a lot, but still I didn't find this proposal. If it was instead take my sincere apologies and please forget this mail. The disturbing part of the "self parameter" is the asymmetry of the definition and the

  1   2   3   >