[Python-ideas] Re: Add Standard String Literals and Prefixes for Mathematical Notation

2020-02-25 Thread David Mertz
(Un)Happily we have the keyword "as" already. They can make their own aliases. On Tue, Feb 25, 2020, 11:46 PM Steven D'Aprano wrote: > On Tue, Feb 25, 2020 at 10:08:57PM -0500, David Mertz wrote: > > > >>> from statistics import stdev as σ > > >>> σ([5, 6, 4, 6, 3, 7]) > > 1.4719601443879744 >

[Python-ideas] Re: Add Standard String Literals and Prefixes for Mathematical Notation

2020-02-25 Thread Chris Angelico
On Wed, Feb 26, 2020 at 3:43 PM Steven D'Aprano wrote: > > On Tue, Feb 25, 2020 at 10:08:57PM -0500, David Mertz wrote: > > > >>> from statistics import stdev as σ > > >>> σ([5, 6, 4, 6, 3, 7]) > > 1.4719601443879744 > > > > :-) > > You know what you've done now, don't you? Somebody is going to

[Python-ideas] Re: Add Standard String Literals and Prefixes for Mathematical Notation

2020-02-25 Thread Steven D'Aprano
On Tue, Feb 25, 2020 at 10:08:57PM -0500, David Mertz wrote: > >>> from statistics import stdev as σ > >>> σ([5, 6, 4, 6, 3, 7]) > 1.4719601443879744 > > :-) You know what you've done now, don't you? Somebody is going to propose a whole series of aliased names for statistics and math modules:

[Python-ideas] Re: Add Standard String Literals and Prefixes for Mathematical Notation

2020-02-25 Thread David Mertz
> > For example, the function for calculating standard deviation is written > `statistics.stdev` not `σ`. > What do you mean? >>> from statistics import stdev as σ >>> σ([5, 6, 4, 6, 3, 7]) 1.4719601443879744 :-) -- Keeping medicines from the bloodstreams of the sick; food from the bellies

[Python-ideas] Re: Add Standard String Literals and Prefixes for Mathematical Notation

2020-02-25 Thread Steven D'Aprano
Hi Nathan, On Tue, Feb 25, 2020 at 11:58:58PM +, Nathan Edwards wrote: > I love regular expressions. Regexes' terse syntax are normally considered rather the opposite of Pythonic. > I would love to see Bra-Ket notation and many of the popular > mathematical forms commonly practiced in

[Python-ideas] Re: str(obj) not calling obj.__str__?

2020-02-25 Thread Michael Foord
On Sun, 23 Feb 2020 at 11:25, Michael Foord wrote: > In unittest.mock.MagicMock I solve this problem by having __new__ create a > new subclass for every instantiation. Setting any magic method on the > instance is promoted to the type via __setattr__. That way every instance > can have unique

[Python-ideas] Re: Add Standard String Literals and Prefixes for Mathematical Notation

2020-02-25 Thread Nick Timkovich
Can you provide short, but non-trivial, clear examples of "before" (current Python) and "after" (what you propose it looks like) to demonstrate the advantage? Will it be ambiguous with existing syntax? On Tue, Feb 25, 2020 at 6:10 PM Nathan Edwards wrote: > I love regular expressions. I would

[Python-ideas] Add Standard String Literals and Prefixes for Mathematical Notation

2020-02-25 Thread Nathan Edwards
I love regular expressions. I would love to see Bra-Ket notation and many of the popular mathematical forms commonly practiced in engineering and science supported by the Python language in an expressive and logical way. I feel the need for expressing mathematical concepts in a standardized and

[Python-ideas] Re: Helper to show code to hide warnings

2020-02-25 Thread Kyle Stanley
> 2. Looking it up is hard. If I Google "python ignore warnings" the top result is a Stack Overflow question where neither the accepted answer nor the most upvoted answer mention specifying a module. The second Google result is the Python docs which are not easy to read through. Hmm, I think we

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-25 Thread Caleb Donovick
> > Is there a reason mypy could not assume that all AtomicStr methods that > return strings actually return an AtomicStr, without impacting runtime > behavior...? Maybe it's not possible and I'm just not familiar enough with > the behavior of the type checkers. > I don't know but I could say

[Python-ideas] Helper to show code to hide warnings

2020-02-25 Thread Alex Hall
This is inspired by the [discussion on iterable strings](https://mail.python.org/archives/list/python-ideas@python.org/thread/WKEFHT4JYCL2PMZ5LB6HJRLVP3OGZI56/), although I think it has applications elsewhere. Sometimes programs emit warnings that need to be filtered out. Maybe they're coming

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-25 Thread David Mertz
I can imagine the hypothetical binary tilde being pretty for some kind of equivalence. This is definitely not enough to motivate me to actually want to add it. But I think this would read OK as equivalent: numpy.allclose(arr1, arr2) arr1 ~ arr2 However, the problem is that there are

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-25 Thread Rhodri James
On 24/02/2020 21:07, Alex Hall wrote: This response honestly seems to ignore most of the paragraph that it's responding to. It being a sharp distinction doesn't matter because consistency isn't axiomatically valuable. Actually I think it is. Or more precisely, I think inconsistency is

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-25 Thread Oscar Benjamin
On Mon, 24 Feb 2020 at 17:47, Aaron Hall via Python-ideas wrote: > > The context for this is statistics , so I'll quote Wolfram on tilde in the > context of statistics: http://mathworld.wolfram.com/Tilde.html > > "In statistics, the tilde is frequently used to mean "has the distribution >

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-25 Thread Steve Jorgensen
Steven D'Aprano wrote: > On Sun, Feb 23, 2020 at 11:25:12PM +0200, Alex Hall wrote: > > "Strings are not iterable - you cannot loop over them > > or treat them as a > > collection. > > Are you implying that we should deprecate the in operator for > strings > too? I would not get rid of the `in`