[Python-ideas] Re: Implementing a 'but' statement in for-iterations

2021-06-29 Thread Henk-Jaap Wagenaar
I think the more realistic option is to allow "if" in the for statement. This has been suggested before, you can find it in the archives. On Mon, 28 Jun 2021, 22:50 Max Shouman, wrote: > This is more of a syntactic sugar than an actual new feature, but... > Exactly, 'but' is the idea: a special

[Python-ideas] Re: The Pattern Matching Wildcard Is A Bad Idea

2021-06-02 Thread Henk-Jaap Wagenaar
This was discussed/litigated/holy wars fought over at extreme length, I suggest you peruse the email archives searching for PEP 622 or 634 and also this might be a helpful jumping off point: https://github.com/gvanrossum/patma/issues. On Wed, 2 Jun 2021 at 04:18, Julia Schmidt wrote: > From

[Python-ideas] Re: symbolic math in Python

2021-05-19 Thread Henk-Jaap Wagenaar
On Wed, 19 May 2021 at 07:41, Martin Teichmann wrote: > Hi list, > > To frame the problem, let us try to solve the equation x ** 2 == 1/2 > using sympy: > > >>> from sympy import Eq, solve, symbols, S > >>> x = symbols("x") > >>> solve(Eq(x**2, S(1)/2)) > [-sqrt(2)/2, sqrt(2)/2]

[Python-ideas] Allow trailing operators [was: allow initial comma]

2021-03-12 Thread Henk-Jaap Wagenaar
This is a definite tangent. Trailing commas are great for reducing git diffs, not making errors when moving things around (missing commas, which e.g. in strings causes concatenation) but I have often wondered whether the same could be extended to (some?) logical or arithmetic operators, in

[Python-ideas] Re: [Python-Dev] Re: Have virtual environments led to neglect of the actual environment?

2021-02-24 Thread Henk-Jaap Wagenaar
On Wed, 24 Feb 2021 at 10:18, Antoine Pitrou wrote: > On Tue, 23 Feb 2021 20:29:52 -0500 > Jonathan Goble wrote: > > > > I can't speak for distributors or maintainers [1], but I can speak for > > myself as a user. I run Debian testing (currently bullseye as that is > > preparing for release) as

[Python-ideas] Re: Make for/while loops nameable.

2020-12-07 Thread Henk-Jaap Wagenaar
Just want to say that that is brilliant, and I would have not thought of that, that's a cool idea! Only annoyance is that it introduces an indentation, otherwise it'd be perfect! On Mon, 7 Dec 2020 at 23:30, Daniel Moisset wrote: > For the likely rare situation where I'd want to do this rather

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

2020-10-22 Thread Henk-Jaap Wagenaar
On Fri, 23 Oct 2020 at 06:35, Random832 wrote: > Does anyone else remember when xkcd first mentioned python? The main > selling point it had for it [and the one that was actually literally true, > vs 'import antigravity' which was a semi-satirical bit about the > batteries-included philosophy]

[Python-ideas] Re: 'Infinity' constant in Python

2020-10-19 Thread Henk-Jaap Wagenaar
I have commented on Steven's comments about alephs below. It seems to me that this discussion (on having "different" infinities and allowing/storing arithmetic on them) is dead-on-arrival because: - the scope of people who would find this useful is very small - it would change current behaviour -

[Python-ideas] Re: CPP Namespaces For Python

2020-10-06 Thread Henk-Jaap Wagenaar
I cannot answer for Alperen, but I commonly encounter this when writing testing code: generally I use the format: some_module.py tests/test_some_module.py where it is expected the filename to test a module is "test_module_name.py". However, within that, I might want to namespace based on the

[Python-ideas] Minor contributions to PEPs (Was: PEP 637 - support for indexing with keyword arguments)

2020-09-23 Thread Henk-Jaap Wagenaar
I noticed a sentence that was not completed in PEP 637. Though I have made (pretty minor) contributions to CPython and some other things, it isn't entirely clear to me whether it would be appropriate for me to submit an issue or pull request for this, and what the general policy is?

[Python-ideas] Re: still more use for pathlib.Path ....

2020-08-20 Thread Henk-Jaap Wagenaar
I have no idea how hard/bad/maintenance heavy this would be, but wouldn't the easy way be simply to provide another attribute (e.g. __path__) with what you want and maintain __file__? I've never used a Path object (directly), I feel like I'm missing out now! On Fri, 21 Aug 2020 at 02:09,

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

2020-07-05 Thread Henk-Jaap Wagenaar
I do not agree clamp should be restricted to numeric values. I would expect clamp to be agnostic to the specifics of floats/numbers and like sort expect it to work for any values as long as they compare (using a dunder). I think having something like min=-math.inf is hence right out in my mind. If

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

2020-07-04 Thread Henk-Jaap Wagenaar
On Sat, 4 Jul 2020 at 19:58, Christopher Barker wrote: > Hmm. > > > Since NaN is neither greater than nor less that anything, it seems the > only correct answer to any > Min,max,clamp involving a NaN is NaN. > > Simplifying the signature, in Python we have: def min(*iterable): iterator =

[Python-ideas] Re: Keyword 'THIS'

2020-06-15 Thread Henk-Jaap Wagenaar
*available since Python 3.8. Link here: https://docs.python.org/3/whatsnew/3.8.html On Mon, 15 Jun 2020 at 16:06, Henk-Jaap Wagenaar wrote: > How about using the Walrus operator/assignment expression, since Python > 3.8? > > if this := [i for i in range(10) if i == 5

[Python-ideas] Re: Keyword 'THIS'

2020-06-15 Thread Henk-Jaap Wagenaar
How about using the Walrus operator/assignment expression, since Python 3.8? if this := [i for i in range(10) if i == 5]: print(this) Evaluate: [5] On Mon, 15 Jun 2020 at 16:03, M Bfmv wrote: > Hey all. Ever had some list comprehension hell in your code? > Me neither *whistles 418

[Python-ideas] Re: str.strip: argument maxstrip

2020-05-20 Thread Henk-Jaap Wagenaar
On Wed, 20 May 2020 at 11:34, Alex Hall wrote: > On Wed, May 20, 2020 at 2:46 AM Cameron Simpson wrote: > >> On 19May2020 15:43, David Mertz wrote: >> Reiterating the Python 3.9 suggestion, what about: >> >> salt2 = salt.cutsuffix(('==', '=')) >> > > But if the API was there, I agree this

[Python-ideas] Re: str.strip: argument maxstrip

2020-05-19 Thread Henk-Jaap Wagenaar
David (or somebody else) could you give us some, as real as possible, examples? This will strengthen the case for it! I am confident they exist and are pretty plentiful but I myself am coming up blank thinking about it for a few minutes and documenting them would be good for discussion. On Tue,

[Python-ideas] Re: Optional keyword arguments

2020-05-19 Thread Henk-Jaap Wagenaar
I think only using the first third of the quote makes your argument too terse Steven. To include the second part: "There should be one-- and preferably only one" which implies "It is preferable there is exactly one qualified pilot in the cockpit", and we arrive (if abbreviated) at what James

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

2020-05-17 Thread Henk-Jaap Wagenaar
On Sun, 17 May 2020 at 15:45, Thierry Parmentelat < thierry.parmente...@inria.fr> wrote: > > > > On 17 May 2020, at 16:31, Bernardo Sulzbach < > berna...@bernardosulzbach.com> wrote: > > > > I would like to comment that the graphical presentation, at least in > IDEs/where the font can be

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

2020-05-17 Thread Henk-Jaap Wagenaar
I would like to comment that the graphical presentation, at least in IDEs/where the font can be controlled, can be achieved using fonts: https://stackoverflow.com/questions/41774046/enabling-intellijs-fancy-%E2%89%A0-not-equal-to-operator On Sun, 17 May 2020 at 13:26, Thierry Parmentelat <

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

2020-05-08 Thread Henk-Jaap Wagenaar
which are compared to each others in asserts). On Fri, 8 May 2020 at 16:23, Alex Hall wrote: > On Fri, May 8, 2020 at 5:11 PM Ethan Furman wrote: > >> On 05/08/2020 07:50 AM, Alex Hall wrote: >> > On Fri, May 8, 2020 at 4:46 PM Henk-Jaap Wagenaar wrote: >> >> On F

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

2020-05-08 Thread Henk-Jaap Wagenaar
On Fri, 8 May 2020 at 14:16, Steven D'Aprano wrote: > On Thu, May 07, 2020 at 03:43:23PM +0200, Dominik Vilsmeier wrote: > > > >We could define this .EQ. operate as *sequence equality*, defined very > > >roughly as: > > > > > > def .EQ. (a, b): > > > return len(a) == len(b) and

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

2020-05-07 Thread Henk-Jaap Wagenaar
Why use "." which has clear syntax problems? This can already be done in current Python (this was linked to in a previous thread about something else) using a generic solution if you change the syntax: https://pypi.org/project/infix/ You could write it as |EQ|, ^EQ^, ... and have it in its own

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

2020-05-06 Thread Henk-Jaap Wagenaar
knowledge of maths enough seeing an opportunity... On Wed, 6 May 2020 at 07:18, Steven D'Aprano wrote: > On Wed, May 06, 2020 at 02:58:01AM +0100, Henk-Jaap Wagenaar wrote: > > > I don't think that is accurate to represent as a representation of "a > > mathematician"

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

2020-05-05 Thread Henk-Jaap Wagenaar
On Wed, 6 May 2020 at 01:41, Greg Ewing wrote: > On 6/05/20 2:22 am, jdve...@gmail.com wrote: > > However, if sets and frozensets are "are considered to be > > fundamentally the same kind of thing differentiated by mutability", > > as you said, why not tuples and lists? > > I think that can be

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

2020-05-05 Thread Henk-Jaap Wagenaar
On Tue, 5 May 2020, 18:24 Steven D'Aprano, wrote: > On Tue, May 05, 2020 at 05:26:02PM +0100, Henk-Jaap Wagenaar wrote: > > > This is a straw man in regards to backwards compatibility. This > particular > > (sub)thread is about whether if this zip-is-strict either a

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

2020-05-05 Thread Henk-Jaap Wagenaar
y 2020, 16:41 Rhodri James, wrote: > On 05/05/2020 13:53, Henk-Jaap Wagenaar wrote: > > Brandt's example with ast in the stdlib I think is a pretty good example > of > > this. > > > > On Tue, 5 May 2020 at 13:27, Rhodri James wrote: > > > >> On 05/05

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

2020-05-05 Thread Henk-Jaap Wagenaar
(presumably by making it the default behaviour of zip). On Tue, 5 May 2020, 17:17 Chris Angelico, wrote: > On Wed, May 6, 2020 at 1:44 AM Rhodri James wrote: > > > > On 05/05/2020 13:53, Henk-Jaap Wagenaar wrote: > > > Brandt's example with ast in the stdlib I think is

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

2020-05-05 Thread Henk-Jaap Wagenaar
Brandt's example with ast in the stdlib I think is a pretty good example of this. On Tue, 5 May 2020 at 13:27, Rhodri James wrote: > On 05/05/2020 13:12, Henk-Jaap Wagenaar wrote: > > A function that is a "safer" version in some "edge case" (not extra > > func

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

2020-05-05 Thread Henk-Jaap Wagenaar
I feel like that argument is flawed. I cannot think of another good example (I am sure there are plenty!) but there is a big difference for discoverability between: A function that does something *different* and functionality does not exist in a built-in (or whatever namespace you are

[Python-ideas] Re: Auto-assign attributes from __init__ arguments

2020-05-04 Thread Henk-Jaap Wagenaar
You are not the first to have this idea. Unless I am mistaken you might find what you are looking for in dataclasses which were added in Python 3.7: https://docs.python.org/3/library/dataclasses.html On Mon, 4 May 2020 at 19:06, Lewis Ball wrote: > Hi All, > > First of all, if this is

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

2020-05-02 Thread Henk-Jaap Wagenaar
ValueError will also catch it if point's internal list contains a bad entry (e.g. a string that does not convert to a float). Having these exceptions does not take anything away as they can choose the more general version. On Sat, 2 May 2020 at 11:12, Eric V. Smith wrote: > On 5/2/2020 6:00 AM, Henk-

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

2020-05-02 Thread Henk-Jaap Wagenaar
On Fri, 1 May 2020 at 10:29, Steven D'Aprano wrote: [...] > "Is it UnpackingOverflowException or PackingUnderflowError or > TooManyValuesUnpackException or ValueUnpackingError or ...???" > It took me far too long to learn the difference between > UnicodeEncodingError and UnicodeDecodingError. Or

[Python-ideas] Re: Optimize out unused variables

2020-04-08 Thread Henk-Jaap Wagenaar
I like the idea of formalizing "unused variables". How about having a syntax for it? Allowing a "." instead of an identifier to signify this behaviour [reusing Serhiy's examples]: head, ., rest = path.partition('/') first, second, *. = line.split() for . in range(10): ... [k for k, . in pairs]

[Python-ideas] Improving Traceback for Certain Errors by Expanding Source Displayed

2020-02-10 Thread Henk-Jaap Wagenaar
Dear Ideas, TL;DR include multiple lines in traceback when appropriate (expressions broken up over multiple lines) to make it easier to spot error from looking at traceback Apologies if this has been suggested/discussed before. I am suggesting that if you do: ``` [ x for x in 0 ] ``` the

Re: [Python-ideas] if in for-loop statement

2017-02-23 Thread Henk-Jaap Wagenaar
I think, in that particular example, that is an ok solution, however if you are combining multiple booleans to create a lambda or separate function that is quite a bit of syntactical sugar to add (unless it is re-used). H-J On 23 February 2017 at 18:11, Régis Martin wrote: >

Re: [Python-ideas] if in for-loop statement

2017-02-23 Thread Henk-Jaap Wagenaar
aybe links to these threads? Maybe that is something that could save you (and others subscribed) time and effort? H-J On 23 February 2017 at 15:02, Paul Moore <p.f.mo...@gmail.com> wrote: > On 23 February 2017 at 14:20, Henk-Jaap Wagenaar > <wagenaarhenkj...@gmail.com> wrote: > > &g

Re: [Python-ideas] if in for-loop statement

2017-02-23 Thread Henk-Jaap Wagenaar
be honest this is a pretty big nail in the coffin. H-J On 23 February 2017 at 14:51, Jelle Zijlstra <jelle.zijls...@gmail.com> wrote: > 2017-02-23 5:37 GMT-08:00 Henk-Jaap Wagenaar <wagenaarhenkj...@gmail.com>: > > > > Hi all, > > > > Often I have typed something

[Python-ideas] if in for-loop statement

2017-02-23 Thread Henk-Jaap Wagenaar
ps://mail.python.org/pipermail/python-dev/2007-November/075257.html), and that thread itself suggests it has been suggested before and shutdown by Guido (though no source is given for this). All the best, Henk-Jaap Wagenaar ___ Python-ideas mailing list Pyt