[Python-ideas] Re: Add builtin function for min(max())

2020-07-04 Thread Dan Sommers
ed by the laughter of the gods.” – Albert Einstein Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/py

[Python-ideas] Re: giving set.add a return value

2020-06-27 Thread Dan Sommers
On Saturday, June 27, 2020, at 03:46 -0500, Chris Angelico wrote: I grew up with concurrency being a perfectly normal thing. To me, EVERYTHING is concurrent. (Back then, it was single-core CPUs, so technically most machine code instructions could be assumed to be atomic, but at any higher l

[Python-ideas] Re: giving set.add a return value

2020-06-27 Thread Dan Sommers
On Friday, June 26, 2020, at 23:25 -0500, Steven D'Aprano wrote: On Fri, Jun 26, 2020 at 06:16:05AM -0500, Dan Sommers wrote: >already_there = seen.add(element) >if already_there: ># handle the duplicate case > >Who thinks like that? *wink* Anyone who p

[Python-ideas] Re: giving set.add a return value

2020-06-26 Thread Dan Sommers
On Friday, June 26, 2020, at 04:54 -0500, Steven D'Aprano wrote: On Thu, Jun 25, 2020 at 05:27:16PM +0300, Ben Avrahami wrote: Hey all, Often I've found this kind of code: seen = set() for i in iterable: if i in seen: ... # do something in case of duplicates else: seen.add(i)

[Python-ideas] Re: Python WebAssembly Support

2020-06-15 Thread Dan Sommers
On Monday, June 15, 2020, at 16:03 -0500, redrad...@gmail.com wrote: Thanks, but I know about this implementation ... But my question is why not to apply all this patches to `CPython` ... And my question is: are *you* prepared to develop, test, maintain, and support this for the next N

[Python-ideas] Re: Bringing the print statement back

2020-06-10 Thread Dan Sommers
On Wednesday, June 10, 2020, at 19:14 -0500, Chris Angelico wrote: On Wed, Jun 10, 2020 at 10:08 AM Guido van Rossum wrote: One thing that the PEG parser makes possible in about 20 lines of code is something not entirely different from the old print statement. I have a prototype: Python 3

[Python-ideas] Re: JSON Serializing UUID objects

2020-06-10 Thread Dan Sommers
On Wednesday, June 10, 2020, at 10:37 -0500, Chris Angelico wrote: On Thu, Jun 11, 2020 at 1:35 AM Eric V. Smith wrote: On 6/10/2020 11:00 AM, Chris Angelico wrote: > On Thu, Jun 11, 2020 at 12:45 AM Dan Sommers > <2qdxy4rzwzuui...@potatochowder.com> wrote: >> If yo

[Python-ideas] Re: JSON Serializing UUID objects

2020-06-10 Thread Dan Sommers
On Wednesday, June 10, 2020, at 08:48 -0500, Alex Hall wrote: On Wed, Jun 10, 2020 at 3:42 PM J. Pic wrote: I understand, do you think the python standard library should provide a JSONEncoder and JSONDecoder that supports python standard library objects ? It would be optional to use, bu

[Python-ideas] Re: Optional keyword arguments

2020-05-28 Thread Dan Sommers
On Thursday, May 28, 2020, at 06:47 -0400, Alex Hall wrote: > On Thu, May 28, 2020 at 12:38 PM Greg Ewing > wrote: > >> On 28/05/20 8:57 pm, Steven D'Aprano wrote: >> > The default value used by a parameter is certainly important, and one of >> > the most common reasons I call `help(func)` is t

[Python-ideas] Re: Optional keyword arguments

2020-05-26 Thread Dan Sommers
On Tuesday, May 26, 2020, at 08:10 -0400, David Mertz wrote: [...] > Well, ok functions.reduce() really does make it's own sentinel in > order to show NONE as a "plain value". So I'll grant that one case is > slightly helped by a hypothetical 'undef'. In Python, 'undef' makes me think of undoi

[Python-ideas] Re: Function composition

2020-05-24 Thread Dan Sommers
On Sunday, May 24, 2020, at 18:58 -0400, Chris Angelico wrote: > Maybe it's function call syntax that is the weird one. It might be > familiar to us, but maybe it's the one that's actually causing the > weirdness. Suppose we wrote the function last: > > (data)sort > > Now it's basically becom

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Dan Sommers
On Sunday, May 24, 2020, at 08:07 -0400, Steven D'Aprano wrote: > On Sun, May 24, 2020 at 02:27:00PM +0300, Ram Rachum wrote: > >> Today I wrote a script and did this: >> >> sorted(paths, key=lambda path: len(str(path)), reverse=True) >> >> But it would have been nicer if I could do this: >

[Python-ideas] Re: Enhance list.index with a comparison function

2020-05-23 Thread Dan Sommers
On Saturday, May 23, 2020, at 11:02 -0400, David Mertz wrote: > Still, generator comprehension are great. And next() is an excellent > function. Agreed, on both counts. I often end up needing an arbitrary element of a set (or the only element of a single-element set), and next(iter(set)) scrat

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-22 Thread Dan Sommers
On Friday, May 22, 2020, at 8:28, Steven D'Aprano wrote: > On Thu, May 21, 2020 at 09:43:33AM -0400, Dan Sommers wrote: > >> I had a customer who was old enough to >> use upper case letter O for zero and lower case letter l for 1 because >> she was old enough t

[Python-ideas] Re: type hints : I'd like to suggest allowing unicode → as an alternative to ->

2020-05-21 Thread Dan Sommers
;m not for full blown, use every Unicode character we can, but I'm not against using characters outside the ISO 646 invariant character set, either. Using π or ϖ as an alias for math.pi? Not too bad. Matched pairs of left/right quotation marks? Maybe, but not without a lot more though

[Python-ideas] Re: Improve handling of Unicode quotes and hyphens

2020-05-10 Thread Dan Sommers
included the bad character, or pointed to it, then the error > becomes a lot more clear. Agreed. -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing list -- python-ideas@python.o

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

2020-05-10 Thread Dan Sommers
stead of using our software. Our solution was to use "illegal" filenames that the shell rejected, but that an application could access directly anyway. I guess the point is that "sanitize" can mean different things to different parts of a system. Dan -- “Atoms are not thin

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-08 Thread Dan Sommers
On Fri, 8 May 2020 17:40:31 -0700 Andrew Barnert via Python-ideas wrote: > So, the OP is right that (1,2,3)==[1,2,3] would sometimes be handy, > the opponents are right that it would often be misleading, and the > question isn’t which one is right ... That's a good summary. Thank you. :-) > [

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-08 Thread Dan Sommers
On Sat, 9 May 2020 03:39:53 +1000 Steven D'Aprano wrote: > This proposal is a narrow one: its the same as list or tuple equality, > but duck-typed so that the container type doesn't matter. Okay. Good. "Container," however, is a dangerous word in this context. According to https://docs.pytho

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-08 Thread Dan Sommers
On Sat, 9 May 2020 04:29:46 +1000 Steven D'Aprano wrote: > On Fri, May 08, 2020 at 07:52:10PM +0200, Alex Hall wrote: > > > Would the proposal come with a new magic dunder method which can be > > overridden, or would it be like `is`? > > An excellent question! I don't think there needs to be a

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-08 Thread Dan Sommers
On Sat, 9 May 2020 03:01:15 +1000 Steven D'Aprano wrote: > On Thu, May 07, 2020 at 11:04:16AM -0400, Dan Sommers wrote: > > On Thu, 7 May 2020 21:18:16 +1000 > > Steven D'Aprano wrote: > > > > > > The strongest equality is the "is" operat

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-08 Thread Dan Sommers
new function or operator isn't onerous, and I often learn things when that happens). -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe sen

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-07 Thread Dan Sommers
question and not a sharp stick.) FWIW, I agree: list != tuple. When's the last time anyone asked for the next element of a tuple? (Okay, if your N-tuple represents a point in N-space, then you might iterate over the coordinates in order to discover a bounding box.) Dan -- “Atoms are not

[Python-ideas] Re: Equality between some of the indexed collections

2020-05-07 Thread Dan Sommers
g] libraries, or without a coherent design. These all seem like appliction level (or even design level) problems, or maybe a series of dunder methods / protocols to define various levels of equivalence (the ability of my inbox and my brain to handle the resulting bikeshedding notwithstanding).

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

2020-05-06 Thread Dan Sommers
d, but that's no a likely occurrance.) Dan -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.

[Python-ideas] Passing Arguments Through Thin Wrappers (was : Auto-assign attributes from __init__ arguments)

2020-05-05 Thread Dan Sommers
en't thought it through. Yes, it borders on magic, and may impinge on implicit vs. explicit. But evidently, Steven and I share this particular pattern, although I never considered it enough of a problem to "solve." Dan -- “Atoms are not things.” – Werner Heisenberg Dan Sommers,

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

2020-05-04 Thread Dan Sommers
default, and let that 10% (where did that number come from?) turn if off because they actually do know better. Dan -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing list -- python-i

[Python-ideas] Re: Introduce 100 more built-in exceptions

2020-05-01 Thread Dan Sommers
your software to "guide" the evolution if more information is encoded in the type of the exception rather than in a human readable message. But that also seems rather unlikely.) Dan -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan __

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

2020-04-26 Thread Dan Sommers
On Mon, 27 Apr 2020 10:11:01 +1000 Steven D'Aprano wrote: > On Sun, Apr 26, 2020 at 06:43:06PM +0200, Alex Hall wrote: > > > It's not clear to me why people prefer an extra function which would be > > exactly equivalent to lru_cache in the expected use case (i.e. decorating a > > function withou

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-23 Thread Dan Sommers
On Fri, 24 Apr 2020 07:46:43 +1000 Steven D'Aprano wrote: > On Thu, Apr 23, 2020 at 04:24:18PM -0400, Dan Sommers wrote: > > On Thu, 23 Apr 2020 14:47:48 -0400 > > Kyle Lahnakoski wrote: > > > > Many of the function keyword parameters I deal with are data pr

[Python-ideas] Re: Keyword arguments self-assignment

2020-04-23 Thread Dan Sommers
name for certain properties. But the whole application? That sounds like a recipe for future inflexibility. -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing list -- python-ideas@python

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

2020-04-21 Thread Dan Sommers
long an iterator is without consuming it. But at that point, why would zip have a post condition involving the caller's iterables? -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing l

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-04-01 Thread Dan Sommers
On Wed, 01 Apr 2020 10:50:29 -0700 Brendan Barnwell wrote: > ... we must demand that the language itself be renamed to something > less offensive and more accurate, such as > ConvenientProgrammingLanguage ... ITYM convenient_programming_language. See PEP 8, Naming Conventions, Method Names and

[Python-ideas] Re: PEP 9999: Retire animal-unfriendly language

2020-03-31 Thread Dan Sommers
On Tue, 31 Mar 2020 19:17:18 +0200 Gerrit Holl wrote: > Abstract > > Python has long used metasyntactic variables that are based on the > consumption of meat and dairy products, such as "spam", "ham", and > "eggs". > This language is not considerate to pigs or chicken and violates the

[Python-ideas] Re: Compound with .. else statement

2020-03-30 Thread Dan Sommers
finally: cleanup() Whether the call to prepare goes inside or outside the try block depends on many things, mostly its coupling to the cleanup procedure (e.g., do they need to share objects? is cleanup idempotennt?). HTH, Dan -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, htt

[Python-ideas] Re: Adding a built-in data structure with binary search tree semantics

2020-03-15 Thread Dan Sommers
Or are all of your account data only stored in memory? Dan -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-l

[Python-ideas] Re: Really long ints

2020-02-05 Thread Dan Sommers
s data, rather > than placed in source code files. (For example, this would allow these > large pieces of data to be verified, via a secure hash.) +1 -- “Atoms are not things.” – Werner Heisenberg Dan Sommers, http://www.tombstonezero.net/dan __

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-02 Thread Dan Sommers
On 1/2/20 3:07 PM, Random832 wrote: > On Thu, Jan 2, 2020, at 13:22, Dan Sommers wrote: >> What about "if except" (any time I can eliminate a "not," that's a >> good thing): > > ... is this meant to be for the doesn't-throw case or does-thr

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-02 Thread Dan Sommers
On 1/2/20 12:55 PM, Andrew Barnert via Python-ideas wrote: > On Jan 2, 2020, at 06:32, Random832 wrote: >> Mainly, you had mentioned you felt like "if try" had a 'smell' to it >> but couldn't figure out what it is, and I was trying help identify >> that, and... well, after thinking about it mor

[Python-ideas] Re: Target-and-expression lists and if-try

2020-01-01 Thread Dan Sommers
On 1/1/20 10:02 AM, Steven D'Aprano wrote: # Fail() is a function that raises an exception; # __ is a special predefined Pattern that always matches. result = match(vec, # object to match Pattern(0, 'y', 'z'), handle_yz, Pattern('x', 0, 'z'), handle

[Python-ideas] Re: Differentiate variables form everything else

2019-11-18 Thread Dan Sommers
On 11/18/19 4:53 PM, Andrew Barnert via Python-ideas wrote: > On Nov 18, 2019, at 13:14, Chris Angelico wrote: >> I wasn't aiming that at you, so much as pointing out how incredibly >> tricky it is to pin down all these definitions. So tricky, in fact, >> that it's almost completely not worth t

[Python-ideas] Re: Suggest having a mechanism to distinguish import sources

2019-11-08 Thread Dan Sommers
On 11/8/19 11:28 AM, Anders Hovmöller wrote: >> On 8 Nov 2019, at 18:06, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: >> On 11/8/19 10:40 AM, Jonathan Fine wrote: >>> I think we can learn from Unix/Linux here. Like python, it has a PATH >>>

[Python-ideas] Re: Suggest having a mechanism to distinguish import sources

2019-11-08 Thread Dan Sommers
On 11/8/19 10:40 AM, Jonathan Fine wrote: Hi All I think we can learn from Unix/Linux here. Like python, it has a PATH variable for finding executables. It also has a command 'which'. Python already has a "-v" option: -v Print a message each time a module is initialized, showing

[Python-ideas] Re: Percent notation for array and string literals, similar to Perl, Ruby

2019-10-23 Thread Dan Sommers
On 10/23/19 6:07 AM, Ricky Teachey wrote: I would expect %w{ ... } to return a set, not a list:     %w[ ... ]  # list     %w{ ... ]  # set     %w( ... )  # tuple and I would describe them as list/set/tuple "word literals". Unlike list etc displays [spam, eggs, cheese

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-21 Thread Dan Sommers
On 10/21/19 9:51 AM, Steven D'Aprano wrote: Dicts are a key:value store, not a multiset, and outside of specialised subclasses like Counter, we can't expect that adding the values is meaningful or even possible. "Adding the values" is too specialised and not general enough for dicts ... Iterab

[Python-ideas] Re: Support for atomic types in Python

2019-09-14 Thread Dan Sommers
On 9/14/19 6:35 AM, Steven D'Aprano wrote: Am I the only one seeing two copies of each of Andrew Barnert's replies? No. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mai

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

2019-09-05 Thread Dan Sommers
On 9/4/19 5:38 PM, Andrew Barnert via Python-ideas wrote: > On Sep 4, 2019, at 08:54, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: >> How does blocking the submit call differ from setting max_workers in >> the call to ThreadPoolExecutor? > Here’s a conc

[Python-ideas] Re: Add a "block" option to Executor.submit

2019-09-04 Thread Dan Sommers
On 9/4/19 11:08 AM, Joao S. O. Bueno wrote: I second that such a feature would be useful, as I am on the verge of implementing a work-around for that in a project right now. I'm sure I'm missing something, but isn't that the point of a ThreadPoolExecutor? Yes, you can submit more requests tha

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

2019-08-04 Thread Dan Sommers
On 8/4/19 1:13 PM, Anders Hovmöller wrote: >> On 3 Aug 2019, at 12:18, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: >> Once I know what SMTP is, and what the smtplib module does, and I've >> used it a couple of times, then seeing the list of names insi

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

2019-08-04 Thread Dan Sommers
On 8/3/19 4:15 AM, Steven D'Aprano wrote: On Fri, Aug 02, 2019 at 02:16:52PM -0400, Dan Sommers wrote: I agree, but that's assuming that you "know" what's there and just have to be reminded. IMO, it helps less with discovering new functions, and even less t

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

2019-08-02 Thread Dan Sommers
On 8/2/19 1:18 PM, David Mertz wrote: > I'm definitely on the old side of the distribution of programmers ... Throw me into that bucket, too. I use autocomplete to save typing rather than to discover new functionality. Autocompletion is great, if you know where to start. In the case that star

[Python-ideas] Re: Namespace context managers

2019-07-26 Thread Dan Sommers
On 7/26/19 12:23 PM, Ricky Teachey wrote: >> >> The class statement works in this fashion. >> > I would argue there are at least 2 significant reasons why a separate > namespace would be preferred over using class in this way: [...] > 2. using class means that all of the "new style class" ma

[Python-ideas] Re: Coding using Unicode

2019-07-15 Thread Dan Sommers
On 7/15/19 8:54 AM, Steven D'Aprano wrote:  = .(, ) I call foul. At least tentatively. For the moment. http://www.unicode.org/reports/tr31/ and http://www.unicode.org/reports/tr39/ specifically exclude private use characters, like U+E24C, from identifiers. And

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Dan Sommers
On 6/24/19 12:32 PM, James Lu wrote: > I think > > print("Remember to wear sunscreen!") if hot_outside unless Weather.is_raining() > > Is more readable than > > if hot_outside and not Weather.is_raining(): print("Remember to wear sunscreen!") I disagree, but that's bound to happen in a discu

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-19 Thread Dan Sommers
On 6/18/19 1:25 PM, Stephen J. Turnbull wrote: > Dan Sommers writes: > > > How would I "think of types as collections of their instances"? > > The canonical example of a type as a collection of instances is an > enumeration, the simplest (useful) example of which

[Python-ideas] Re: Comparison operator support (>= and <=) for type

2019-06-16 Thread Dan Sommers
On 6/16/19 7:49 AM, Franklin? Lee wrote: > On Sat, Jun 15, 2019 at 10:26 PM Guido van Rossum wrote: >> I don't actually know how viable this proposal is, but given that >> it's being debated at some length, I'd like to put in my opinion that >> *if* we're going to define an operator that's (r

Re: [Python-ideas] Sorted lists

2019-04-08 Thread Dan Sommers
On 4/8/19 6:25 AM, Steven D'Aprano wrote: > On Mon, Apr 08, 2019 at 02:55:54AM -0700, Nathaniel Smith wrote: >> If only we had some kind of API that could compute multiple quantiles at >> the same time... > > You mean something like this? > > quartiles, quintiles, deciles, percentiles = quan

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

2019-04-01 Thread Dan Sommers
On 4/1/19 9:34 PM, David Mertz wrote: On Mon, Apr 1, 2019, 8:54 PM Steven D'Aprano wrote: The point I am making is not that we must not ever support multiple affixes, but that we shouldn't rush that decision. Let's pick the low-hanging fruit, and get some real-world experience with the functio

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Dan Sommers
On 4/1/19 11:35 AM, Anders Hovmöller wrote: Please let's all agree that April 1 is the worst day of the year. I can't reproduce your problem. What version of Python are you running, and on what OS? Please show us your program, and tell us what you expected it to do and what it did that failed

Re: [Python-ideas] Backward-incompatible changes for Python 4

2019-04-01 Thread Dan Sommers
On 4/1/19 10:27 AM, Antoine Pietri wrote: - The / operator returns floats, which loses information when both of the operands are integer. In Python 4, “1 / 2” should return a decimal.Decimal. To ease the transition, we propose to add a new “from __future__ import decimal_division” in Python 3.9

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

2019-03-31 Thread Dan Sommers
On 3/31/19 1:48 AM, Chris Angelico wrote: If we're bikeshedding the actual method names, I think it would be good to have a list of viable options. A quick skim through the thread gives me these: * cut_prefix/cut_suffix * strip_prefix/strip_suffix * cut_start/cut_end * Any of the above with the

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

2019-03-30 Thread Dan Sommers
On 3/30/19 9:03 AM, David Mertz wrote: On Sat, Mar 30, 2019, 8:42 AM Steven D'Aprano wrote: Most of us have had to cut a prefix or a suffix from a string, often a file extension. Its not as common as, say, stripping whitespace, but it happens often enough. I do this all the time! I never re

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

2019-03-25 Thread Dan Sommers
On 3/25/19 7:01 AM, Jonathan Fine wrote: Chris Angelico asked: what does a negative string look like? This is a very good question. It looks a bit like a negative number. >>> 2 + 2 4 >>> len('aa' + 'bb') 4 >>> len(-'bb') -2 # Odd, I must confess. >>> 5 + (-1)

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

2019-03-24 Thread Dan Sommers
On 3/24/19 6:45 PM, Cameron Simpson wrote: Like others I'm against the name 'trim" itself because of PHP's homonym which means what "strip" means in Python (and therefore doesn't mean what "trim" is proposed to mean here). "clip"? I'm +0.9 rather than +1 entirely because the operation feels so.

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

2019-03-21 Thread Dan Sommers
On 3/21/19 9:19 PM, Christopher Barker wrote: https://docs.python.org/3.8/library/collections.html has some examples using collections.Counter, which is clearly described as being a subclass of dict. Amongst the examples: c + d # add two counters together: c[x] + d[x] That's the + oper

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

2019-03-21 Thread Dan Sommers
On 3/21/19 6:46 PM, Steven D'Aprano wrote: Antoine and Serhiy seem to worry that there are existing uses of + which are currently easy to understand but will become less so if dict.__add__ is added. I respect that worry, even if I doubt that they are correct. If someone can demonstrate that the

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

2019-03-21 Thread Dan Sommers
On 3/21/19 1:01 PM, Jonathan Fine wrote: Rémi Lapeyre wrote: Not matter the notation you end up choosing, I think this code: https://github.com/jpadilla/pyjwt/blob/master/jwt/utils.py#L71-L81 [...] would greatly benefit from a new merge to merge dicts. I've looked at the merge_dict defined in

Re: [Python-ideas] Why operators are useful

2019-03-18 Thread Dan Sommers
On 3/18/19 7:12 PM, Steven D'Aprano wrote: > On Mon, Mar 18, 2019 at 06:34:48PM -0500, Dan Sommers wrote: > >> So how many of you got tired of those three statements and >> added something like the following function to your private >> collection of useful functions:

Re: [Python-ideas] Why operators are useful

2019-03-18 Thread Dan Sommers
On 3/18/19 6:08 PM, Steven D'Aprano wrote: On Mon, Mar 18, 2019 at 03:12:52PM +0100, Antoine Pitrou wrote: (also, don't forget you can still use the copy() + update() method) If we had fluent method calls, we could write: process(mapping.copy().update(other)) but we don't, so we use a

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Dan Sommers
On 3/16/19 6:17 AM, Richard Damon wrote: On 3/16/19 4:39 AM, Greg Ewing wrote: Rémi Lapeyre wrote: I think this omit a very important property of mathematic equations thought, maths is a very strongly typed language which can be a significant improvement for readability. Python is very strong

Re: [Python-ideas] Code version evolver

2019-03-15 Thread Dan Sommers
On 3/15/19 2:34 PM, francismb wrote: I understand that no one really wants to annoy the language users by breaking the code and that's why those changes are considered carefully. Is that may be because there is no easy way to write a translator? or there is no translator to help transition? T

Re: [Python-ideas] Left arrow and right arrow operators

2019-03-13 Thread Dan Sommers
On 3/13/19 1:44 PM, David Teresi wrote: `->` would not be ambiguous in the proposed cases, but it does already mean something elsewhere in the language as of 3.5: def concat(a: str, b: str) -> str: return a + b This could potentially cause confusion (as with the % operator being used for m

Re: [Python-ideas] Dict joining using + and +=

2019-03-04 Thread Dan Sommers
On 3/4/19 5:11 PM, Steven D'Aprano wrote: On Mon, Mar 04, 2019 at 11:56:54AM -0600, Dan Sommers wrote: On 3/4/19 10:44 AM, Steven D'Aprano wrote: > If you know ahead of time which order you want, you can simply reverse > it: > > # prefs = site_defaults + user_def

Re: [Python-ideas] Dict joining using + and +=

2019-03-04 Thread Dan Sommers
On 3/4/19 10:44 AM, Steven D'Aprano wrote: > If you know ahead of time which order you want, you can simply reverse > it: > > # prefs = site_defaults + user_defaults + document_prefs > prefs = dict(ChainMap(document_prefs, user_defaults, site_defaults)) > > but that seems a little awkwa

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread Dan Sommers
On 3/1/19 8:19 AM, Ivan Levkivskyi wrote: On Fri, 1 Mar 2019 at 13:48, INADA Naoki wrote: > > > Is that an invariant you expect to apply to other uses of the + > operator? > > py> x = -1 > py> x <= (x + x) > False > > py> [999] <= ([1, 2, 3] + [999]) > False > Please calm down. I meant each

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

2019-02-22 Thread Dan Sommers
On 2/21/19 10:33 PM, Steven D'Aprano wrote: (And did they ever stop to wonder why those old terminals standardized on 80 columns?) Punch cards? https://softwareengineering.stackexchange.com/questions/148677 There's an ensuing discussion regarding the history of the size/shape of the punch ca

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

2019-02-21 Thread Dan Sommers
On 2/21/19 7:06 PM, Chris Barker via Python-ideas wrote: > On Thu, Feb 21, 2019 at 12:01 PM Raymond Hettinger > wrote: >> class Frabawidget: >> ... >> @wozzle.setter >> def (self, woozle): >> if not (self.min_woozle < woozle < self.max_woozle): >> raise ValueError

Re: [Python-ideas] add fluent operator to everything

2019-02-20 Thread Dan Sommers
On 2/20/19 7:46 PM, Christopher Barker wrote: > mutating operations vs copying operations > > functions vs methods. > > This has a lot of impact on the design, and it's very important that > any final syntax makes these distinctions clear. Absolutely. > On Wed, F

Re: [Python-ideas] add fluent operator to everything

2019-02-20 Thread Dan Sommers
On 2/20/19 9:10 AM, Steven D'Aprano wrote: > That's possibly a matter of familiarity. I'd be very surprised if you > preferred this: > > mystr = mystr.strip() > mystr = mystr.expandtabs() > mystr = mystr.lower() > mystr = mystr.replace('ham', 'spam') > result = function(m

Re: [Python-ideas] add fluent operator to everything

2019-02-20 Thread Dan Sommers
On 2/20/19 1:58 AM, Jimmy Girardet wrote: You're right on it. The str class is a  straightforward swiss army knife with methods you can chain. list or dict do not fit this idea. Python strings are immutable. Python lists and dicts are not. Both classes are straightforward. __

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

2019-02-19 Thread Dan Sommers
On 2/19/19 11:06 AM, Anders Hovmöller wrote: > Maybe you know some grep magic I don't? Is there a way to> do multi > line grep that knows that open paren means to ignore new lines until > the matching close paren? I'd love to hear about it! At the risk of jumping in over my head with respect to

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

2019-02-19 Thread Dan Sommers
On 2/19/19 8:28 AM, Samuel Colvin wrote: > Let's take a real life example from here > > (changed very slightly for this example), in tranitional python the > signature might be: > > def resolve_annotations(raw_annotat

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Dan Sommers
On 2/1/19 4:07 PM, Abe Dillon wrote: One thing that's nice about Reddit is you can link to posts, so if you've already discussed something at length in another thread, you can simply refer to that discussion. Mailman keeps an archive of all email sent to the python mailing list, and the individ

Re: [Python-ideas] Running Python commands from a Shell

2019-02-01 Thread Dan Sommers
On 2/1/19 3:48 PM, Steven D'Aprano wrote: > On Fri, Feb 01, 2019 at 02:38:43PM -0600, Dan Sommers wrote: > >> So why not turn that around? ksh (since way back when) and >> bash (since 2008, according to what I read somewhere online) >> have "co-processes,&quo

[Python-ideas] Fwd: Re: Running Python commands from a Shell

2019-02-01 Thread Dan Sommers
On 2/1/19 2:51 PM, Chris Angelico wrote: On Sat, Feb 2, 2019 at 7:39 AM Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: On 2/1/19 2:26 AM, João Matos wrote: > Hello, > > > Consider adding the option of running shell/console commands inside the REPL. > So

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Dan Sommers
On 2/1/19 2:58 PM, Abe Dillon wrote: [Dan Sommers] A mailing list is not a feed... Dan, a decades and decades long fan of mailing lists and real email clients. I'm only familiar with Gmail which keeps reply chains coherent and moves each chain to the top of my "forums" t

Re: [Python-ideas] Running Python commands from a Shell (was: Option of running shell/console commands inside the REPL)

2019-02-01 Thread Dan Sommers
On 2/1/19 2:26 AM, João Matos wrote: Hello, Consider adding the option of running shell/console commands inside the REPL. Something like !dir I first ran into this in the days of teletypes and dumb terminals, where other programs let you run shell commands from inside them. Now the shoe app

Re: [Python-ideas] Clearer communication

2019-02-01 Thread Dan Sommers
On 2/1/19 1:01 PM, Abe Dillon wrote: > [Steven D'Aprano] > >> This isn't Facebook or Reddit, where +1 Likes cause messages to move >> to the top of your feed. (And thank goodness for that.) This is a >> technical mailing list where the worth of a proposals usually depends >> on merit, not the numb

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

2019-01-05 Thread Dan Sommers
On 1/5/19 12:21 PM, Mike Miller wrote:> > On 1/5/19 12:34 AM, Ivan Levkivskyi wrote: > > > There is. Mypy supports final names, final methods and whatnot > > https://mypy.readthedocs.io/en/latest/final_attrs.html > > > Believe this^^ is the best answer, unfortunately buried. The type hinting is

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

2018-12-24 Thread Dan Sommers
On 12/24/18 7:33 AM, Steven D'Aprano wrote: > On Mon, Dec 24, 2018 at 03:01:07PM +0200, Andrew Svetlov wrote: >> Handling files overcomplicates both implementation and mental space >> for API saving. > I haven't thought about this very deeply, but at first glance, I like > Drew's idea of being a

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-02 Thread Dan Sommers
On 11/2/18 7:39 AM, Anders Hovmöller wrote:> >> So far, I count 12 people who responded to the original post by >> Giampaolo. By my count, I see: >> >> * five people in favour; >> * three people against, or see no need for it; >> * four people I can't tell if they are for or against, >> (possib

Re: [Python-ideas] TypeHinting: From variable name to type

2018-10-22 Thread Dan Sommers
On 10/22/18 9:04 AM, Steven D'Aprano wrote: My IDE is Unix. (Technically, Linux.) +1 Or just google https://duckduckgo.com/?q=unix+as+an+ide Thank you for not verbing DuckDuckGo! :-) ... (I use an actual GUI editor, not Vim or Emacs) ... [ ... must ... resist ... holy war ... ] Dan _

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

2018-09-28 Thread Dan Sommers
On 9/28/18 8:32 PM, Chris Angelico wrote: On Sat, Sep 29, 2018 at 10:22 AM Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: On 9/28/18 7:39 PM, Steven D'Aprano wrote: But none of that compares to C undefined behaviour. People who think that they are equivalent, don

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

2018-09-28 Thread Dan Sommers
On 9/28/18 8:12 PM, Chris Angelico wrote: On Sat, Sep 29, 2018 at 7:19 AM Greg Ewing wrote: Chris Angelico wrote: It is still fundamentally difficult to make assertions about the file system as pre/post contracts. When you consider race conditions, I'd say it's impossible. A postcondition c

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

2018-09-28 Thread Dan Sommers
On 9/28/18 7:39 PM, Steven D'Aprano wrote: On Fri, Sep 28, 2018 at 07:18:54PM +0200, 2qdxy4rzwzuui...@potatochowder.com wrote: On 9/28/18 12:45 PM, Steven D'Aprano wrote: On Tue, Sep 25, 2018 at 09:59:53PM +1000, Hugh Fisher wrote: C and Python (currently) are known as simple languages. o

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-23 Thread Dan Sommers
On Thu, 23 Aug 2018 21:40:12 +1000, Steven D'Aprano wrote: > On Wed, Aug 22, 2018 at 06:50:29PM +0000, Dan Sommers wrote: >> On Thu, 23 Aug 2018 03:44:07 +1000, Steven D'Aprano wrote: >> >> > On Wed, Aug 22, 2018 at 12:11:40PM -0500, Abe Dillon wrote: >&g

Re: [Python-ideas] Does jargon make learning more difficult?

2018-08-22 Thread Dan Sommers
On Thu, 23 Aug 2018 03:44:07 +1000, Steven D'Aprano wrote: > On Wed, Aug 22, 2018 at 12:11:40PM -0500, Abe Dillon wrote: > difflib tests include this call: > > sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ', ...) > > which becomes: > > sm = difflib.SequenceMatcher(isjunk=x == ' ' with x,

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-04 Thread Dan Sommers
On Sat, 04 Aug 2018 23:13:34 +1000, Steven D'Aprano wrote: > There are certainly advantages to using binary operators over named > functions, and a shortage of good, ASCII punctuation suitable for new > operators. Hold that thoght. Then again, why is it 2018 (or 5778?) and we're still stuck with

Re: [Python-ideas] A partial (wacky?) alternative to assignment expressions

2018-05-14 Thread Dan Sommers
On Tue, 15 May 2018 10:35:58 +1000, Steven D'Aprano wrote: > We would need to flag which expression can be cached because it is > PURE, and tag how far the CACHE operates over: > > > > func(arg) > > + func(arg)*2 + func(arg)**2 > > > This would

Re: [Python-ideas] Objectively Quantifying Readability

2018-05-01 Thread Dan Sommers
On Wed, 02 May 2018 05:08:41 +1000, Steven D'Aprano wrote: > The difference was that when Windows users used the mouse, even though > they were *objectively* faster to complete the task compared to using > the arrow keys, subjectively they swore that they were slower, and > were *very confident* a

  1   2   >