[Python-ideas] Re: Abstract dataclasses and dataclass fields

2023-12-22 Thread Chris Angelico
On Sat, 23 Dec 2023 at 07:13, DL Neil via Python-ideas wrote: > > On 12/23/23 02:09, Eric V. Smith via Python-ideas wrote: > > On 12/21/2023 4:38 PM, Steve Jorgensen wrote: > >> I am finding that it would be useful to be able to define a dataclass that > >> is an abstract base class and define

[Python-ideas] Re: re.match(pattern, string, require=True)

2023-10-22 Thread Chris Angelico
On Mon, 23 Oct 2023 at 01:14, Juancarlo Añez wrote: > > The re module is a black swan, because most of stdlib raises exceptions on > invalid arguments or not being able to deliver. > This is a comparison function, and like every other comparison function, it signals its results with a return

[Python-ideas] Re: re.match(pattern, string, require=True)

2023-10-21 Thread Chris Angelico
On Sun, 22 Oct 2023 at 11:29, MRAB wrote: > I think what the OP wants is to have re.match either return a match or > raise an exception. Yes, and my point is that simply attempting to access an attribute will do exactly that. It's not a silent failure. Why create a new argument, then mandate

[Python-ideas] Re: re.match(pattern, string, require=True)

2023-10-21 Thread Chris Angelico
On Sun, 22 Oct 2023 at 06:37, Ram Rachum wrote: > > On Sat, Oct 21, 2023 at 10:30 PM Chris Angelico wrote: >> >> >> > I love that, but it mostly makes sense for "if there's a match do this, >> > otherwise do that" where most cases fall into &

[Python-ideas] Re: re.match(pattern, string, require=True)

2023-10-21 Thread Chris Angelico
On Sun, 22 Oct 2023 at 06:11, Ram Rachum wrote: > > On Sat, Oct 21, 2023 at 10:01 PM Chris Angelico wrote: >> >> On Sat, 21 Oct 2023 at 21:57, Ram Rachum wrote: >> >> What about an if with the match inside it? >> >> if m := re.match(...): >>

[Python-ideas] Re: re.match(pattern, string, require=True)

2023-10-21 Thread Chris Angelico
On Sat, 21 Oct 2023 at 21:57, Ram Rachum wrote: > > It's a little similar to the reasoning behind PEP 618 (adding the `strict` > argument to `zip`). Not quite, since without strict, zip will truncate - it doesn't have a different return value. > A keyword argument is easier to add, and makes

[Python-ideas] Re: Extract variable name from itself

2023-09-25 Thread Chris Angelico
On Mon, 25 Sept 2023 at 22:04, Dom Grigonis wrote: > > I think a lot has been said by this time and I have nothing to add. > > If this is something that is of value, I am sure it will be picked up when > the time is right. > > One last thing that I think could be of some use is a poll: > >

[Python-ideas] Re: Extract variable name from itself

2023-09-24 Thread Chris Angelico
On Mon, 25 Sept 2023 at 10:05, Dom Grigonis wrote: > > What is your position on this? > > Do you think that such thing is worth having? > > If yes, do any of the 3 final options seem sensible to you? > My position is that so far, you haven't shown it to be of much value. Which might be because

[Python-ideas] Re: Extract variable name from itself

2023-09-24 Thread Chris Angelico
On Mon, 25 Sept 2023 at 07:05, Dom Grigonis wrote: > What I meant is that functions in __builtins__ are low level, with > functionality which is hidden from the user. > What does that even mean? ChrisA ___ Python-ideas mailing list --

[Python-ideas] Re: Extract variable name from itself

2023-09-24 Thread Chris Angelico
On Mon, 25 Sept 2023 at 00:15, Dom Grigonis wrote: > I see what you mean, but this property is arguably intrinsic to what it is. > And is part of f-strings vs explicit formatting property too: > > variable = 1 > print(f'{variable=} and b={variable}') > # VS > msg = 'variable={v} and b={v}' >

[Python-ideas] Re: Extract variable name from itself

2023-09-16 Thread Chris Angelico
On Sat, 16 Sept 2023 at 19:48, Jeff Allen wrote: > It needs language (parser) support because it does what you identified early > on: "take whatever is given and put it in quotes", where "whatever is given" > is the text of the expression only available at run-time. > I didn't say "and put it

[Python-ideas] Re: Extract variable name from itself

2023-09-15 Thread Chris Angelico
On Sat, 16 Sept 2023 at 10:20, Dom Grigonis wrote: > > So following this thread, from your perspective and from what has been said > you can’t see or noticed any parts of it needing interpreter? Correct. Trying to get a variable name from an object is nonsensical, and trying to get a variable

[Python-ideas] Re: Extract variable name from itself

2023-09-15 Thread Chris Angelico
On Sat, 16 Sept 2023 at 10:07, Dom Grigonis wrote: > > > > def nameof(x): return x > > > > print("This " + nameof("thing") + " is:", thing) > Can you explain what you meant by this code? How would this work in editor? > Frankly, I have no idea, because your **entire proposal** is predicated on

[Python-ideas] Re: Extract variable name from itself

2023-09-15 Thread Chris Angelico
On Sat, 16 Sept 2023 at 08:50, Jeff Allen wrote: > The parallel with f-string = is helpful, for which compile-time support is > essential, of course. It's really something that needs editor support, not compiler support. As far as the Python interpreter is concerned, this is just a string. So

[Python-ideas] Re: Extract variable name from itself

2023-09-12 Thread Chris Angelico
On Tue, 12 Sept 2023 at 20:05, Dom Grigonis wrote: > > Please read the next part of my e-mail too. It actually answer your question. > I did read it, and it didn't answer the question. Your desired semantics are not clear. ChrisA ___ Python-ideas

[Python-ideas] Re: Extract variable name from itself

2023-09-12 Thread Chris Angelico
On Tue, 12 Sept 2023 at 19:51, Dom Grigonis wrote: > > It wouldn’t. I know this is weird and not in line of how things work. This is > more about simply getting reference variable name in locals() from the > reference itself. But how would one access the variable name, when once > called it

[Python-ideas] Re: Have del return a value

2023-09-07 Thread Chris Angelico
On Thu, 7 Sept 2023 at 23:51, Daniel Walker wrote: > > Perhaps this is a solution in search of a problem but I recently encountered > this situation in one of my projects. > > I have an object, foo, which, due to the references it contains, I'd rather > not keep around longer than necessary. >

[Python-ideas] Re: factory for sentinel objects

2023-08-31 Thread Chris Angelico
On Thu, 31 Aug 2023 at 18:55, Tim Hoffmann via Python-ideas wrote: > > The standard pattern to create a sentinel in Python is > > >>> Unset = object() > > While this is often good enough, it has some shortcomings: > > - repr(Unset) is unhelpful: > Looks like you may be thinking of this:

[Python-ideas] Re: while(tt--)

2023-08-21 Thread Chris Angelico
On Tue, 22 Aug 2023 at 05:34, Wes Turner wrote: > > On Sat, Aug 19, 2023, 7:27 PM Celelibi wrote: >> >> 2023-08-04 8:18 UTC+02:00, daniil.arashkev...@gmail.com >> : >> > Currently in Python we have construction like this: >> > >> > tt = 5 >> > while t: >> > # do something >> > tt -= 1 >>

[Python-ideas] Re: while(tt--)

2023-08-19 Thread Chris Angelico
On Sun, 20 Aug 2023 at 09:28, Celelibi wrote: > Just as a reminder of C/C++: {pre,post}-{inc,dec}rementations bring > their lot of issues with the language. Mostly the infamous *undefined > behavors*. If you've done some C or C++ this very expression might > send shivers down your spine. The

[Python-ideas] Re: else without except

2023-08-07 Thread Chris Angelico
On Tue, 8 Aug 2023 at 00:09, Celelibi wrote: > Actually, now that I think about it, I guess a 'try' block without an > 'except' and just a 'finally' would probably be a good candidate for a > context manager. (Which I'm a big fan of. ^^) Yeah, context managers are often a good way of writing a

[Python-ideas] Re: Conditional 1-line expression in python

2023-08-05 Thread Chris Angelico
On Sat, 5 Aug 2023 at 22:49, Dom Grigonis wrote: > 3. The Python syntax is easily understandable to anyone who knows English as > it follows English syntax: "What are you doing tonight?" "I'm going to the > movies, if I manage to leave work on time, otherwise I'll just stay home.” > * Is the

[Python-ideas] Re: Conditional 1-line expression in python

2023-08-05 Thread Chris Angelico
On Sat, 5 Aug 2023 at 22:49, Dom Grigonis wrote: > 9. Python has a syntax for conditional expressions. Learn it, if you want to > use Python. No need to create multiple syntaxes for the same thing. > * Hello Chris A? :) Nope. ChrisA ___

[Python-ideas] Re: else without except

2023-08-01 Thread Chris Angelico
On Wed, 2 Aug 2023 at 08:22, Mitch wrote: > > If `except` is omitted, then catch the generic exception and do nothing and > exit. > Not sure what you mean here. If you have a try-finally with no except clause, no exceptions will be caught; the try will be run, then the finally, and then you'll

[Python-ideas] Re: else without except

2023-08-01 Thread Chris Angelico
On Wed, 2 Aug 2023 at 04:03, Mitch wrote: > I'll ask the same question as OP: "Is there a reason why else without except > has to be invalid syntax?" > A better question is: "Is there a reason why else without except should be valid syntax?" ChrisA

[Python-ideas] Re: else without except

2023-08-01 Thread Chris Angelico
On Wed, 2 Aug 2023 at 02:02, Celelibi wrote: > If later on an "except" is added, the developper doing the > modification should be reminded to move the call to > no_error_occurred() into an "else". With real-world non-trivial code, > it might not be so simple to see. > Can you give us an example

[Python-ideas] Re: "Curated" package repo?

2023-07-25 Thread Chris Angelico
On Wed, 26 Jul 2023 at 01:20, Jonathan Crall wrote: > > > On Mon, Jul 24, 2023 at 10:04 AM Chris Angelico wrote: > > can you tell me what this vetting procedure proves that isn't already > > proven by mere popularity itself? > > I think that's what this thread is t

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-24 Thread Chris Angelico
On Tue, 25 Jul 2023 at 01:03, Dom Grigonis wrote: > I think what would be nice to have is a set of dimensions that are deemed to > be of importance when deciding on a language constructs. > plot(dim1, dim2, dim3) > dim1 - number of lines > dim2 - number of terms > dim3 - number of operations >

[Python-ideas] Re: "Curated" package repo?

2023-07-24 Thread Chris Angelico
On Mon, 24 Jul 2023 at 23:28, Jonathan Crall wrote: > > If popular packages weren't favored that would be a problem. Popularity > should be correlated with "trustworthiness" or whatever the metric this > curated repo seeks to maximize. I think the important thing is that the > packages are

[Python-ideas] Re: "Curated" package repo?

2023-07-24 Thread Chris Angelico
On Mon, 24 Jul 2023 at 21:02, James Addison via Python-ideas wrote: > ... some thoughts on how to build a scalable, resilient trust network based > on user ratings; I can't guarantee that it'll change your opinion, though! > This still has the fundamental problems of any sort of user rating

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Chris Angelico
On Sun, 23 Jul 2023 at 14:08, Dom Grigonis wrote: > > IT IS AN OBJECT. Never said otherwise. One that you can't do any of the operations I described. There is no way to use it as an object. > `inspect.getcallargs` can seemingly be modified for such behaviour. I just > wrote a decorator, which

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Chris Angelico
On Sun, 23 Jul 2023 at 12:20, Dom Grigonis wrote: > > > > There is no way to have a value that isn't a value, in Python. The > > concept doesn't make sense and would break all kinds of things. > > (That's why, when a special function like __getitem__ has to be able > > to return literally

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-07-22 Thread Chris Angelico
On Sun, 23 Jul 2023 at 09:15, Dom Grigonis wrote: > This works ok: > > ``` > def foo(bar=None): > if bar is None: > bar = A() > > class A: > pass > ``` > > If PEP is aiming to replace the latter example, then it would be great if it > kept all of its advantages. I.e. not having

[Python-ideas] Re: Conditional 1-line expression in python

2023-07-21 Thread Chris Angelico
On Fri, 21 Jul 2023 at 19:58, Dom Grigonis wrote: > > Did not mean that it is easy, but it seems achievable and although a deep dig > might be needed, my gut feeling is that it is possible to achieve this fairly > elegantly. I might be wrong ofc. > Start on that deep dig, then, and figure out

[Python-ideas] Re: Conditional 1-line expression in python

2023-07-21 Thread Chris Angelico
On Fri, 21 Jul 2023 at 19:15, Dom Grigonis wrote: > However, it could be done differently as well. If `Break()` takes effect in > the scope where it is evaluated. Then: > You say that as if it's easy. How would this work? How do you have a function that, when called, causes the current loop to

[Python-ideas] Re: Conditional 1-line expression in python

2023-07-20 Thread Chris Angelico
On Fri, 21 Jul 2023 at 11:08, Dom Grigonis wrote: > Also, can't find a way to ONLY force evaluation without any additional > operations in this specific library. A simple callable which evaluates if > unevaluated & returns would do. Then: > > def IF(condition, when_true, when_false): > if

[Python-ideas] Re: Conditional 1-line expression in python

2023-07-20 Thread Chris Angelico
On Fri, 21 Jul 2023 at 05:53, Random832 wrote: > > On Mon, Jul 17, 2023, at 16:41, Dom Grigonis wrote: > > Would be interesting to see if my preference is an outlier or not really. > > I think this is a false dichotomy. We should consider VB-like conditional > expressions if(condition,

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-20 Thread Chris Angelico
On Thu, 20 Jul 2023 at 22:27, Stephen J. Turnbull wrote: > > Chris Angelico writes: > > On Thu, 20 Jul 2023 at 15:33, Stephen J. Turnbull > > wrote: > > C'mon Chris, "that was then, this is now". Catch up, I've changed my > position. ;-) > That's f

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-20 Thread Chris Angelico
On Thu, 20 Jul 2023 at 19:34, Dom Grigonis wrote: > And ideally, adding 2 builtin(or imported from stdlib) functions: `Break` and > `Continue`, which if called act as `break` and `continue` statements. > How would they work? Would every function call have to provide the possibility to return to

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-20 Thread Chris Angelico
On Thu, 20 Jul 2023 at 18:16, Greg Ewing wrote: > > On 20/07/23 6:30 pm, James Addison via Python-ideas wrote: > > result = default if bar is None else bar > > or if you prefer > > result = bar if bar is not None else default > > Would it shut anyone up if we had another logical

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-20 Thread Chris Angelico
On Thu, 20 Jul 2023 at 17:09, Dom Grigonis wrote: > > On 20 Jul 2023, at 09:48, anthony.flury wrote: > In Python then a better way might be > > result = temp := bar() if temp else default > > This way only bar() and default are evaluated and invoked once. > I presume you want a more complicated

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-20 Thread Chris Angelico
On Thu, 20 Jul 2023 at 15:33, Stephen J. Turnbull wrote: > I didn't like that PEP then; I was in the camp of "let's get genuine > Deferreds, and use them to cover some of the use cases for PEP 671." You're almost certainly never going to get that, because "genuine Deferreds", as well as being

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Chris Angelico
On Wed, 19 Jul 2023 at 11:51, Dom Grigonis wrote: > > Coming back to deferred evaluation, > > https://peps.python.org/pep-0671/ > These 2 aren’t really orthogonal in functionality. Maybe in implementation. > But PEP671 is a certain subset of deferred evaluation as it can achieve the > same with

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-18 Thread Chris Angelico
On Wed, 19 Jul 2023 at 06:41, Dom Grigonis wrote: > > When you put it from this perspective, it seems to make sense, however, I do > not agree. > > To me, from first principles it seems it’s all about condensing more > complexity in smaller modular packages. > > That is why I am a bit confused,

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-18 Thread Chris Angelico
On Wed, 19 Jul 2023 at 00:55, Dom Grigonis wrote: > Here I am a bit confused, how is this the case in the language containing > list comprehensions? > Do you understand the difference between expressiveness and terseness? You still seem to be focused on the completely wrong thing here. List

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-18 Thread Chris Angelico
On Tue, 18 Jul 2023 at 23:41, Stephen J. Turnbull wrote: > 2. Comparing floats, even against zero, is a bad idea. So I would > wrap them in math.isclose: > > val = a ? (not isclose(c, 0) ? c : d) : (not isclose(d, 0) ? d : c) That's overly simplistic; there are a lot of times when it's

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Chris Angelico
On Tue, 18 Jul 2023 at 19:02, Dom Grigonis wrote: > > Thank you. > > I meant “superset of 671, not 505”… > > One question: > > def bar(a => None); > return foo(a) > > def foo(a => object()): > return a > > How would I force foo’s default from bar’s call? That's a known-hard problem. The

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-18 Thread Chris Angelico
On Tue, 18 Jul 2023 at 16:25, Dom Grigonis wrote: > > Yes, thank you, this would definitely be nice to have. > > Although, "A generic system for deferred evaluation has been proposed at > times“ sound better if it was a superset of PEP505. Could you refer me to any > resources about such

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 14:07, Dom Grigonis wrote: > PEP505 would solve this nicely, but it only applies to None and would not > apply to say user-defined sentinels and many other cases where permutations > of different conditionals arise. > PEP 671 would solve this nicely too. ChrisA

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 10:37, Dom Grigonis wrote: > As opposed to > > if a == 0: >foo, bar = var1, variable2 > else: >foo, bar = default, default2 > > > Again, one is `a == 0`, another is `b == 0`. I didn’t do a good job conveying > this did I… Will try to be more precise and leave less

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 08:56, Dom Grigonis wrote: > > Just to add, I think your statement actually works in my favour rather than > against my proposal. > > People from this group are potentially biased and lack objectivity against > what I am proposing because they are familiar with python and

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 08:38, Dom Grigonis wrote: > > > Was that really the intention? Because I was there when PEP 572 was > > written, and I don't recall "beautiful one-liners" as one of the > > justifying reasons. Use around if/while conditions was a strong > > reason, and yes, that can save a

[Python-ideas] Re: Conditional 1-line expression in python (Dom Grigonis)

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 08:34, Dom Grigonis wrote: > > I still feel that compared to list comprehension and other functional and > elegant python constructs, python's if-else expression is lacking. I often > choose to go multi-line much more verbose code as opposed to more brief > constructs

[Python-ideas] Re: Conditional 1-line expression in python

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 06:43, Dom Grigonis wrote: > > Hi everyone, > > I am not very keen on long discussions on such matter as I do not think there > is much to discuss: there is no technical complexity in it and it doesn’t > really change or introduce anything new. It is only a matter of

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 06:40, Dom Grigonis wrote: > > We even got a new operator “:=“ to help us with those beautiful one-liners > (or not) to move towards aesthetics and brevity. > Was that really the intention? Because I was there when PEP 572 was written, and I don't recall "beautiful

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 04:37, Dom Grigonis wrote: > > This is NOT a good example, my first language was R, second - python, third > matlab, etc. > > I only became familiar with C/C++ after several years of coding experience. > > This is why, I would dare to say that this preference of mine is

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-17 Thread Chris Angelico
On Tue, 18 Jul 2023 at 03:13, Dom Grigonis wrote: > Maybe for someone who majored in languages python’s if-else is more easily > understood. To me, personally, 2nd one is unbearable, while 1st one is fairly > pleasant and satisfying. > This is a REALLY good example of how hard it is to be

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-15 Thread Chris Angelico
On Sun, 16 Jul 2023 at 04:07, Jothir Adithyan wrote: > > Chris Angelico wrote: > > On Tue, 11 Jul 2023 at 08:05, Jothir Adithyan adithyanjot...@gmail.com > > wrote: > > > Assumptions: > > > The problem statement is based on a few assumptions: > > &g

[Python-ideas] Re: Proposal for get_or function in Python dictionaries

2023-07-10 Thread Chris Angelico
On Tue, 11 Jul 2023 at 08:05, Jothir Adithyan wrote: > Assumptions: > > The problem statement is based on a few assumptions: > - You prefer chaining `get` statements for cleaner code. > - You expect at least some of the `get` methods to return `None`. > - You want to avoid the hassle of using

[Python-ideas] Re: "Curated" package repo?

2023-07-09 Thread Chris Angelico
On Sun, 9 Jul 2023 at 18:06, James Addison via Python-ideas wrote: > > On Sun, 9 Jul 2023 at 02:11, Cameron Simpson wrote: > > I have always thought that any community scoring system should allow > > other users to mark up/down other reviewers w.r.t the scores presented. > > That markup should

[Python-ideas] Re: "Curated" package repo?

2023-07-05 Thread Chris Angelico
On Thu, 6 Jul 2023 at 04:08, Gregory Disney wrote: > > Why not just use gpg signatures and maintain trusted signing keys? There’s no > reason to reinvent the wheel. If a user wants to use a unsigned or untrusted > packages, they have to accept the risk. > As an alternative to a blockchain? No

[Python-ideas] Re: Double "at" operator for matmul exponentiation

2023-07-05 Thread Chris Angelico
On Thu, 6 Jul 2023 at 04:02, Dom Grigonis wrote: > What I would alternatively propose is to introduce a couple of (meaningless > operators), so that library developers can make use of them as they wish. > What characters aren't used? “$, ?, `” (or are they?). > What should their precedences

[Python-ideas] Re: "Curated" package repo?

2023-07-05 Thread Chris Angelico
On Thu, 6 Jul 2023 at 03:57, James Addison via Python-ideas wrote: > I also agree with a later reply about avoiding the murkier side of > blockchains / etc. That said, it seems to me (again, sample size one > anecdata) that creating a more levelled playing field for package publication >

[Python-ideas] Re: [Suspected Spam]"Curated" package repo?

2023-07-05 Thread Chris Angelico
On Wed, 5 Jul 2023 at 17:12, Stephen J. Turnbull wrote: > > 4) A self contained repository of packages that you could point > > pip to -- it would contain only the packages that had met some > > sort of "vetting" criteria. In theory, anyone could run it, but > > a stamp of

[Python-ideas] Re: "Curated" package repo?

2023-07-05 Thread Chris Angelico
On Wed, 5 Jul 2023 at 17:00, Christopher Barker wrote: > I'm noting this, because I think it's part of the problem to be solved, but > maybe not the mainone (to me anyway). I've been focused more on "these > packages are worthwhile, by some definition of worthwhile). While I think > Chris A is

[Python-ideas] Re: "Curated" package repo?

2023-07-04 Thread Chris Angelico
On Wed, 5 Jul 2023 at 15:07, Jonathan Crall wrote: > > I like the idea of a vetted package index that pip can point to. The more I > think about it, the more I think that it needs some sort of peer review > system as the barrier to entry, and my thoughts to to establishing some DeSci > DAO

[Python-ideas] Re: "Curated" package repo?

2023-07-04 Thread Chris Angelico
On Wed, 5 Jul 2023 at 10:26, Christopher Barker wrote: > The :problem", as I see it. > > - The Python standard library is not, and will never be fully comprehensive > -- most projects require *some* third party packages. > - There are a LOT of packages available on PyPi -- with a very wide

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-02 Thread Chris Angelico
On Sun, 2 Jul 2023 at 16:36, Christopher Barker wrote: > > However, the amount of time the two of us have spent on this thread could > have been used to review the status of quite a few packages :-) > >> >> Indeed. But I expect it'd be easier to get one person to write one >> blog post about

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-02 Thread Chris Angelico
On Sun, 2 Jul 2023 at 15:48, Christopher Barker wrote: >> Only re (the one in the stdlib)? What if you want PCREs - >> there's no package called "pcre" but there's "pcre2", "python-pcre", >> and probably others. > > > And are those three (and others?) actually useful maintained packages? Or >

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-01 Thread Chris Angelico
On Sun, 2 Jul 2023 at 15:11, Christopher Barker wrote: > The OP of this thread is not alone -- folks want an authoritative source -- > they may not get that An authoritative source is absolutely perfect for someone who wants less choices. "Just give me the one and only option and promise me

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-01 Thread Chris Angelico
On Sun, 2 Jul 2023 at 07:00, Dom Grigonis wrote: > > If it’s curated by more experienced members of this mailing list I would feel > more confident in depending on it and more keen to contribute and review PRs. > Maybe, with luck, if some good robust solution arises, it could be > streamlined

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-01 Thread Chris Angelico
On Sat, 1 Jul 2023 at 22:32, Dom Grigonis wrote: > > Another idea, maybe this group could host a simple git repo. > This has the same problem of who is curating it. If it's uncurated, that's PyPI as it already is. If it's controlled by the PyPA or PSF, then it gives too much authority. ChrisA

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-01 Thread Chris Angelico
On Sat, 1 Jul 2023 at 18:43, Stephen J. Turnbull wrote: > > Chris Angelico writes: > > On Sat, 1 Jul 2023 at 01:15, Christopher Barker > > wrote: > > > > Totally different topic, but I do think that a "curated" package > > > repo wo

[Python-ideas] Re: dict method to retrieve a key from a value

2023-07-01 Thread Chris Angelico
On Sat, 1 Jul 2023 at 16:09, Christopher Barker wrote: >If the PSF recommends a package > > Who said anything about the PSF? ;-) -- but yes, that would be another way > to go -- a tightly curated collection -- lower barrier to entry than the > standard library, but still pretty high. Who

[Python-ideas] Re: dict method to retrieve a key from a value

2023-06-30 Thread Chris Angelico
On Sat, 1 Jul 2023 at 01:15, Christopher Barker wrote: > Totally different topic, but I do think that a "curated" package repo would > be helpful -- there is a lot of cruft on PyPi :-( > That idea gets thrown around every once in a while, but there are a few problems with it. When you "bless"

[Python-ideas] Re: List get/pop

2023-06-14 Thread Chris Angelico
On Thu, 15 Jun 2023 at 06:04, Dom Grigonis wrote: > So following Chris’ logic... > If there are 10,000,000 python users on Stack… > And we assume, that every user encounters such need at least 2 times a year > (being very speculative here, would say conservative?). That was me being VERY

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread Chris Angelico
On Wed, 14 Jun 2023 at 09:05, BoppreH via Python-ideas wrote: > > @ChrisA: There are already flags for enabling warnings on dangerous bytearray > comparisons[1] or relying on locale-dependent encodings[2], not to mention a > whole Development Mode flag[3] that adds extra checks. Some of those

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread Chris Angelico
On Wed, 14 Jun 2023 at 07:52, BoppreH via Python-ideas wrote: > > Sorry, I'm new to the list and was not aware the burden of proof was so high. > Can you point me to one or two successful posts in Python-ideas where I can > learn how to show there's a real need for a feature? > It's more a

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread Chris Angelico
On Wed, 14 Jun 2023 at 07:02, BoppreH via Python-ideas wrote: > > > In close to 10 years of experience with python I have never encountered > > anything like this. > > Here's a small selection of the StackOverflow questions from people who > encountered this exact issue: But now try to find

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread Chris Angelico
On Wed, 14 Jun 2023 at 01:07, BoppreH via Python-ideas wrote: > And I have to say I'm surprised by the responses. Does nobody else hit bugs > like this and wish they were automatically detected? > Nope, I've never had that happen to me, and I *have* made use of calling iter() on

[Python-ideas] Re: Warn when iterating over an already exhausted generator

2023-06-13 Thread Chris Angelico
On Tue, 13 Jun 2023 at 21:03, BoppreH via Python-ideas wrote: > > Any thoughts on logging a warning, perhaps behind an opt-in flag? I could not > find a single false positive scenario, so I expect the signal-to-noise ratio > to be high and prevent lots of bugs. > Shadow the iter() function and

[Python-ideas] Re: yield functionality to match that of await

2023-06-13 Thread Chris Angelico
On Tue, 13 Jun 2023 at 14:54, Greg Ewing wrote: > > On 13/06/23 11:38 am, Chris Angelico wrote: > > (Fun fact: Pike looked at what Python was doing, and came up with a > > concept of "continue functions" > > And I gather that the "async" and "awa

[Python-ideas] Re: yield functionality to match that of await

2023-06-12 Thread Chris Angelico
On Tue, 13 Jun 2023 at 09:33, Greg Ewing wrote: > > On 13/06/23 9:29 am, Dom Grigonis wrote: > > Also, could anyone point me in the direction, where it is explained why new > > await/async syntax was introduced instead of making use of already existing > > yield coroutine functionality? > > To

[Python-ideas] Re: yield functionality to match that of await

2023-06-12 Thread Chris Angelico
On Tue, 13 Jun 2023 at 07:33, Dom Grigonis wrote: > > I was wandering if there are any issues in making `yield` usage to be the > same as that of `await` > > Most importantly: > l.append(yield Object()) You should be able to use that, since yield *is* an expression. The only oddity is, you have

[Python-ideas] Re: Add a .whitespace property to module unicodedata

2023-06-02 Thread Chris Angelico
On Sat, 3 Jun 2023 at 10:12, David Mertz, Ph.D. wrote: > > Let's call the styles a tie. Using the SOWPODS scrabble wordlist (no > currency symbols, so False answer): > > >>> unicode_currency = {chr(c) for c in range(0x) if > >>> unicodedata.category(chr(c)) == "Sc"} > >>> wordlist =

[Python-ideas] Re: Add a .whitespace property to module unicodedata

2023-06-02 Thread Chris Angelico
On Sat, 3 Jun 2023 at 09:42, David Mertz, Ph.D. wrote: > > Yeah... oops. Obviously I typed the version in email. Should have done it in > the shell. But you got the intention of set-ifying the characters in the > large string. Yep. I thought of that as I was originally writing, but absent

[Python-ideas] Re: Add a .whitespace property to module unicodedata

2023-06-02 Thread Chris Angelico
On Sat, 3 Jun 2023 at 08:28, David Mertz, Ph.D. wrote: > > This is just bar talk at this point. I think we've shown that this is > easy enough to do that programmers can roll their own. > > But as idle chat goes, note that in your code: > >set(unicodedata.category(ch) for ch in s) > > If `s`

[Python-ideas] Re: Add a .whitespace property to module unicodedata

2023-06-02 Thread Chris Angelico
On Sat, 3 Jun 2023 at 07:28, David Mertz, Ph.D. wrote: > > Sure. That's fine. With a sufficiently long strings my code is faster, but > for "typical" strings yours will be. Really? How? Your code has to build a set of every character in the string; mine builds a set of every category in the

[Python-ideas] Re: Add a .whitespace property to module unicodedata

2023-06-02 Thread Chris Angelico
On Sat, 3 Jun 2023 at 07:08, David Mertz, Ph.D. wrote: > > def does_string_have_currency_mark(s): > return bool(set(s) & set(unicode_categories['Sc']) > > def does_string_have_numeric_digit(s): ... > > ... and so on. Those seem like questions one asks often enough. Not > every day, but more

[Python-ideas] Re: Add a .whitespace property to module unicodedata

2023-06-02 Thread Chris Angelico
On Sat, 3 Jun 2023 at 06:54, David Mertz, Ph.D. wrote: > > If we're talking PyPI, it would be nice to have: > > unicode_categories = {"Zs": [...], "Ll": [...], ...} > > For all the various categories. It would just take one pass through > all the characters to generate it, but then every

[Python-ideas] Re: Add a .whitespace property to module unicodedata

2023-06-01 Thread Chris Angelico
On Fri, 2 Jun 2023 at 02:27, David Mertz, Ph.D. wrote: > > It feels to me like "split on whitespace" or "remove whitespace" are > quite common operations. I've been frustrated a number of times by > settling for the ASCII whitespace class when I really wanted the > Unicode whitespace class. >

[Python-ideas] Re: Visual Python.

2023-05-19 Thread Chris Angelico
On Sat, 20 May 2023 at 02:53, Michael R wrote: > > To whom it may concern: > > Is it possible to create a Visual Python with options and editing tools > similar to Excel? > In the beginning it could be a combo with a command-docker, calling for a > visual Routine. > Indented structure of coding

[Python-ideas] Re: @lazy decorator an alternative to functools.partial ?

2023-05-17 Thread Chris Angelico
On Thu, 18 May 2023 at 05:14, Daniel Guffey wrote: > > Apologies, I didn't mean to imply PyPI was inherently untrustworthy, > unusable, or irrelevant. Clearly, it has a place and I use it for packages > that I am familiar with and trust. Then I would advise being careful how you word things,

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2023-04-29 Thread Chris Angelico
On Sat, 29 Apr 2023 at 23:01, wrote: > > Ad 4) Wouldn't "<=" be a little more logical than "=>"? The perceived > direction of the "flow" of the default value is exactly opposite, i.e., the > default value is always evaluated and then put *into* the argument. > Using arrows to represent

[Python-ideas] Re: Allowing `str.format` to format one or more parameters instead of all parameters

2023-04-25 Thread Chris Angelico
On Wed, 26 Apr 2023 at 11:18, Joao S. O. Bueno wrote: > Worst case scenario, one goes from one non-running program to a running > program producing partially incorrect output. > Wording that another way: Buggy code, instead of raising an immediate exception, now produces wrong output. This is

[Python-ideas] Re: Protocols Subclassing Normal Classes

2023-04-21 Thread Chris Angelico
On Fri, 21 Apr 2023 at 22:57, Jordan Macdonald wrote: > However, I then encountered an issue: I could define a Protocol that > specified the 'stop()' method easily enough, but if I annotated the manager > as taking that, it would accept any class which implemented a method named > 'stop()',

[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-03 Thread Chris Angelico
On Mon, 3 Apr 2023 at 17:57, Benedict Verhegghe wrote: > > Well, it's not an object of type 'type' like the list or dict mentioned > by the OP, for which len() give a > TypeError: object of type 'type' has no len() I'm not sure what you mean here. Enum is of type EnumMeta, which is a subclass of

[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-03 Thread Chris Angelico
On Mon, 3 Apr 2023 at 15:54, Benedict Verhegghe wrote: > > Enum is not a type, like the OP suggested: > Well, it is: >>> isinstance(Enum, type) True but it has a metaclass, meaning that the type of Enum is a subclass of type. >>> type(Enum) >>> type(Enum).__bases__ (,) I mean, we wouldn't

[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-02 Thread Chris Angelico
On Mon, 3 Apr 2023 at 08:28, Greg Ewing wrote: > > On 2/04/23 6:36 pm, Benedict Verhegghe wrote: > > An Enum is functionally a container with a limited set of constants. Why > > should it not be legitimate to ask for the number of constants in it? > > But Enum itself isn't an enum, it's a

[Python-ideas] Re: C#-style "as" casting syntactic sugar for type hints

2023-03-23 Thread Chris Angelico
On Fri, 24 Mar 2023 at 13:02, Will Bradley wrote: > It would be nice if I could just write "birthDate": > date.strftime(r'%m/%d/%Y') as str, like in C#. I'm sure it would - for you. Unfortunately it would most definitely NOT be nice to write: with something as str: and then be unsure whether

  1   2   3   4   5   6   7   8   9   10   >