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

2023-12-22 Thread Greg Ewing
On 23/12/23 9:12 am, DL Neil via Python-ideas wrote: On 12/23/23 02:09, Eric V. Smith via Python-ideas wrote: You're better off discussing this on discuss.python.org as this mailing list is basically dead. It can't be dead - you're here! It's just resting! -- Greg

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

2023-10-22 Thread Greg Ewing
On 23/10/23 1:36 am, 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. Most of the time, failure to match an re is not a programming error. Often it's perfectly normal. Sometimes it's the result of

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

2023-07-20 Thread Greg Ewing
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 operator: x otherwise y equivalent to x if x is not None

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

2023-07-17 Thread Greg Ewing
On 18/07/23 10:30 am, Dom Grigonis wrote: Although, the argument that python is meant to be read as english is very much valid, but I do not see why it has to be an overarching one if the opportunity cost of it is too great in other dimensions. It's not overarching. Many things in Python

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

2023-06-12 Thread Greg Ewing
On 13/06/23 11:38 am, Chris Angelico wrote: I think they currently use what's basically a copy of the generator implementation. It makes sense to make resumable functions that way. In many ways it does, although things get a bit messy when it comes to async generators. If I were designing

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

2023-06-12 Thread Greg Ewing
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 my mind, the fact that coroutines use the same underlying

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

2023-06-12 Thread Greg Ewing
On 13/06/23 9:59 am, Rob Cliffe via Python-ideas wrote: Also the OP's request was for generators, not for any iterator. IMO it would be a bad idea to make generators behave differently from other iterators in this regard. And it's far too late to redefine the iterator protocol in general,

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

2023-05-18 Thread Greg Ewing
On 19/05/23 4:16 am, Christopher Barker wrote: The problem with "batteries included" is that what exactly is a battery is hard to define, and everyone has a different opinion about it. To my mind, "batteries included" means you can do *something* useful with it out of the box. It doesn't mean

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

2023-04-28 Thread Greg Ewing
On 29/04/23 6:59 am, Bruce Leban wrote: To take this further, suppose you write 'Hello {username} from {company}'.format(userdata).format(companydata) where the user has set their name to "Dr. {secret} Evil" where {secret} is something in companydata that should not be exposed. More

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

2023-04-21 Thread Greg Ewing
On 22/04/23 10:20 am, Samuel Muldoon wrote: Can we change str.formatso that it is possible to change only one string parameter, but leave the other parameters alone? That would have the effect that every use of str.format for everyone would start producing partially-formatted strings if an

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

2023-04-02 Thread Greg Ewing
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 constructor for enums. I think len() just happens to work on it as

[Python-ideas] Re: Better (?) PRNG - follow up

2022-12-05 Thread Greg Ewing
On 6/12/22 3:58 pm, James Johnson wrote: I came back to this thread looking for the list of randomness tests, and I keep missing them somehow. If you're interested in testing a PRNG really thoroughly, check out TestU01: http://simul.iro.umontreal.ca/testu01/tu01.html -- Greg

[Python-ideas] Re: Enhancing variable scope control

2022-12-01 Thread Greg Ewing
On 1/12/22 9:27 am, Anony Mous wrote: The idea is that YOU write "local:", and the interpreter, without you ever seeing it, promotes that into a hidden function with a hidden name and a hidden call. But if that's *all* it does, then this wouldn't happen: I would expect them to return to, or

[Python-ideas] Re: Enhancing variable scope control

2022-11-30 Thread Greg Ewing
On 1/12/22 6:58 am, Anony Mous wrote: local:     for MyVal in range(0,10)         pass provides scoping, making it easier for us to code, debug, and document, while significantly decreasing the likelihood of variable collisions. I'm not convinced it would be beneficial in Python. In C you

[Python-ideas] Re: Void type

2022-07-27 Thread Greg Ewing
On 27/07/22 5:29 am, Stephen J. Turnbull wrote: If you're phishing, I guess worms are useful. *shudder* I think you need whorms for phishing. -- Greg ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: `importlib.resources` access whole directories as resources

2022-05-16 Thread Greg Ewing
On 17/05/22 4:58 am, Christopher Barker wrote: if you want to call your collection of files a single resource, then sure -- but then it's not the directory that's the resource, it's the collection of files that's the resource Sure, but why am I not allowed to use the name of the directory as

[Python-ideas] Re: `importlib.resources` access whole directories as resources

2022-05-16 Thread Greg Ewing
On 16/05/22 5:05 pm, Christopher Barker wrote: a directory is not a binary artifact -- it can't have actually data in it like a file can. and: the entire point of resources is to provide an abstraction -- the individual resources may not be files on disk at all These two statements are

[Python-ideas] Re: New Tool Proposal

2022-05-10 Thread Greg Ewing
On 10/05/22 8:05 pm, anthony.flury via Python-ideas wrote: My Idea is a simple tool that uses introspection tools to take a Python module and to generate the relevant boiler plate for the module - including blank functions for the module classes and for methods. There's a much better tool in

[Python-ideas] Re: Get the value of an attribute of an object hierarchy with a path expression

2022-05-05 Thread Greg Ewing
On 5/05/22 3:53 am, gabor.g...@proinbox.com wrote: I think it is pretty frequent to check that a variable is not None before accessing it's attributes or element. While that's probably true, in my experience I'm usually performing the test once on a particular object and then accessing a

[Python-ideas] Re: Delete dictionary entry if key exists using -= operator via __isub__()

2022-04-29 Thread Greg Ewing
On 29/04/22 6:02 am, Zach Victor wrote: For me, pop() says "give me something." In English the word "pop" doesn't necessarily imply getting something wanted, or even getting anything at all. Think popping a champagne cork, or popping a balloon. -- Greg

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-18 Thread Greg Ewing
On 18/04/22 7:29 pm, malmiteria wrote: It's an arbitrary choice that the C3 feature itself makes, and the programmer is left guessing what that choice was, unless they can take the time to learn C3 in depth. Even if you do, it's still an arbitrary choice to prefer the leftmost method, which

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-17 Thread Greg Ewing
On 16/04/22 10:46 pm, Steven D'Aprano wrote: On Sat, Apr 16, 2022 at 05:56:13PM +1200, Greg Ewing wrote: There's nothing incoherent or inconsistent about the way C++ and Eiffel do MI. Good thing I never said that they were incoherent or inconsistent. You seemed to be implying that, though

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-17 Thread Greg Ewing
On 16/04/22 11:13 pm, Steven D'Aprano wrote: So we might say that all inheritance is delegation, but not all delegation is inheritance. We might even go further and say that any delegation to a superclass (not just the direct parent) is a form of manual inheritance. To my way of thinking,

[Python-ideas] Re: Conditions for a coherent MI relationship [was Re: Re: mro and super don't feel so pythonic]

2022-04-17 Thread Greg Ewing
On 16/04/22 10:26 pm, Steven D'Aprano wrote: C++ and Eiffel are even stricter (more restrictive) than Python. They don't just exclude class hierarchies which are inconsistent, they exclude class hierarchies with perfectly good linearizations because they have a method conflict. No, they don't

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-15 Thread Greg Ewing
On 16/04/22 12:56 pm, Steven D'Aprano wrote: If you exclude models of MI which are logically incoherent and inconsistent, (such as Python's prior to version 2.3), then Python's model of MI is objectively as complete as you can get. You seem to be assuming that "full MI" has to include a fully

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-15 Thread Greg Ewing
On 15/04/22 10:37 pm, Steven D'Aprano wrote: If you look at languages that implement MI, and pick the implementations which allow it with the fewest restrictions, then that is "full MI". I believe that Python (and other languages) allow MI with the smallest set of restrictions, namely that

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-15 Thread Greg Ewing
On 15/04/22 4:45 am, malmiteria wrote: malmiteria xD not malmalitia Sorry! Should have gone to Specsavers... -- Greg ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-13 Thread Greg Ewing
On 13/04/22 8:29 am, Steven D'Aprano wrote: When multiple parent provide candidate to a method resolution, raise an error. Then you aren't doing full MI any more, That sounds like a "true Scotsman" argument. Who defines what "full MI" means? I can think of at least two languages that do

[Python-ideas] Re: Giving Decimal a global context was a mistake?

2022-04-08 Thread Greg Ewing
On 8/04/22 7:03 pm, Christopher Barker wrote: Are you SURE your accounting software is doing the right thing?  ;-) Well, I've only ever seen precision problems manifest themselves once, and that was when I wrote a script that used repeated multiplications by 10 as part of a process to convert

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Greg Ewing
On 7/04/22 11:11 pm, malmiteria wrote: But if there was a way to tell super what class it should be a proxy of, that would be very easy to explain : when there's two parent, just give the parent you want to target as an argument to super. That sounds like exactly what Class.method(self) does

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-08 Thread Greg Ewing
On 7/04/22 11:52 pm, malmiteria wrote: I believe my gobelin exemple is a fair case of MI since we can definitely say halfbreed *is a* corruptedgobelin *and a* proudgobelin. I'm not so sure about that. I would agree that it's a gobelin, just as you are (presumably) a human. But a child is

[Python-ideas] Re: Giving Decimal a global context was a mistake?

2022-04-07 Thread Greg Ewing
On 8/04/22 6:01 am, David Mertz, Ph.D. wrote: Because the module implements http://speleotrove.com/decimal/decarith.html Well, yes, but someone made the decision to implement that particular standard rather than one of the ones with fixed

[Python-ideas] Re: Giving Decimal a global context was a mistake?

2022-04-07 Thread Greg Ewing
On 8/04/22 5:15 am, Christopher Barker wrote: I actually have almost the opposite position -- variable precision is the most useful part of the Decimal type ;-) So can you elaborate on how you use variable precision? Note the docs again: "End users typically would not expect 1.1 + 2.2 to

[Python-ideas] Re: Giving Decimal a global context was a mistake?

2022-04-07 Thread Greg Ewing
On 7/04/22 9:53 am, Chris Angelico wrote: how else would you do variable-precision in the standard library? Maybe the mistake was in thinking that we need variable precision at all. If the goal of Decimal was to provide arithmetic that "works like your calculator", well, most calculators have

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-06 Thread Greg Ewing
On 7/04/22 5:22 am, malmiteria wrote: Also, i believe the idea of using anything but super to access a parent methods is far from obvious to most people. That might be true for people who learned Python recently enough. When I started using Python, super didn't even exist, so I got used to

[Python-ideas] Re: Giving Decimal a global context was a mistake?

2022-04-06 Thread Greg Ewing
On 6/04/22 8:58 pm, Mark Dickinson via Python-ideas wrote: I'd be curious to know what alternatives you see. When a user writes `x + y` with both `x` and `y` instances of `decimal.Decimal`, the decimal module needs to know what precision to compute the result to (as well as what rounding mode

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-06 Thread Greg Ewing
On 6/04/22 10:41 am, Chris Angelico wrote: I don't think anyone would ever say that a parsec (several light years) should be considered equivalent to a second of latitude (a handful of meters) just because they both have an angular size of one second! Although if you're Han Solo then it's a

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-06 Thread Greg Ewing
On 6/04/22 5:52 am, malmiteria wrote: Some exemple i give including, but not limited to the gobelin exemple are a fair use case in which you'd want to use the argumented version of super. No, the gobelin example is an example of when NOT to use super(). Multiple people have told you that,

[Python-ideas] Re: Custom literals, a la C++

2022-04-06 Thread Greg Ewing
On 5/04/22 4:17 pm, Chris Angelico wrote: If your application needs to use both statute and nautical miles in the same module (most likely the main module), then it's going to have an issue, If there's a single global registry, and they both register the unit under the same name, then there

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-05 Thread Greg Ewing
On 6/04/22 4:57 am, Eric Fahlgren wrote: On Tue, Apr 5, 2022 at 7:49 AM Greg Ewing <mailto:greg.ew...@canterbury.ac.nz>> wrote: > It's only there now for backwards compatibility. Not always.  I have an example, where a method creates a closure that calls super, requiring th

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 6/04/22 3:47 am, Christopher Barker wrote: And they are -- degrees latitude and degrees longitude are very different units :-) I'm thinking more of a local Cartesian coordinate system rather than lat-long. Think about this: You're driving north in a car that's 3m long. You turn east. Do

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 6/04/22 3:30 am, Stephen J. Turnbull wrote: suppose I wanted to know how many cm there are in an in: cm_per_in = 1 * in / 1 * cm Of course that's a silly mistake, but the (sole, IMO) advantage of the original proposal is that you can't make that silly mistake. Well, you can make the

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-05 Thread Greg Ewing
On 5/04/22 5:57 am, malmiteria wrote: When you're actually in need to passing arguments to super, you very likely know what class you're gonna be targeting, and having to run MRO logic in reverse to call super to the class that comes first before your target in MRO order is what i refer to as

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 5/04/22 6:36 am, Chris Angelico wrote: 5 L/100km in SI units is 5e-3 m³ / 1e5m. That's 5e-8 m². Or if you prefer, 50mm². Fuel economy is a unit of area. This misses the rather important point that it's not just litres of empty space, it's litres *of fuel*. You really need to consider

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 5/04/22 6:05 am, Ethan Furman wrote: It seems to me that these "unitless' units actually have units, even if they *appear* to cancel each other out. I think it's more that units alone don't capture everything that's important about the physical situation. Another example: the capacitance

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 5/04/22 6:05 am, Chris Angelico wrote: In any case: the speed of light might be 1, but it's still 1 distance divided by 1 time. If you truly embrace the idea of space and time forming a single 4-dimensional continuum, this makes about as much sense as insisting that north-south and

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 5/04/22 5:17 am, Steven D'Aprano wrote: However, I suspect that having an array of unit objects rather than low-level machine ints or floats will reduce the performance of numpy a lot. If numpy were to incorporate units, I would expect there to be just one unit tag for the whole array. --

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 5/04/22 12:27 am, David Mertz, Ph.D. wrote: On Mon, Apr 4, 2022, 2:17 AM Brian McCall > For instance, I don't think there would be much uproar if "teaspoons" were left out of any kind of implementation. Apparently someone other than you does the cooking in you household! Wouldn't

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-05 Thread Greg Ewing
On 4/04/22 10:46 pm, Steven D'Aprano wrote: Now tell me that before you ran the code, or read my analysis of it, you would have predicted that super(ProudGobelin, self) would skip ProudGobelin's method and call CorruptedGobelin's method. I could have told you that it would skip ProudGobelin,

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-05 Thread Greg Ewing
On 4/04/22 7:59 pm, Chris Angelico wrote: How often do you ACTUALLY need them to be local to a module? When is this ever a concern? As long as there are competing *implementations* of units there will be potential for conflicts, even if the actual units being represented are the same. -- Greg

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-04 Thread Greg Ewing
On 4/04/22 3:45 pm, David Mertz, Ph.D. wrote: An electron volt is a unit of energy. Or of mass. Or of momentum. Well, in relativity they're all really the same thing, or at least interconvertible. But there are more glaring examples of this. What do you get when you multiply a number of

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-04 Thread Greg Ewing
On 4/04/22 2:42 pm, Ricky Teachey wrote: height = 5ft + 4.5in Surely we ought to be able to add these values. But what should the resulting tag be? One answer might be that the tag only tracks what kind of quantity it is -- length, mass, time, etc. Internally the number would be represented

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-04 Thread Greg Ewing
On 4/04/22 10:47 am, dn wrote: You wouldn't believe it - have interrupted typing here to receive a package. However, the clothing delivered is NOT the size ordered... Let me guess, you ordered it in cm but they delivered it in inches?-) -- Greg ___

[Python-ideas] Re: Custom literals, a la C++

2022-04-04 Thread Greg Ewing
On 4/04/22 10:20 am, Chris Angelico wrote: import sys sys.register_numeric_suffix("m", lambda n: unit(n, "meter")) sys.register_numeric_suffix("mol", lambda n: unit(n, "mole")) A global registry seems like a really bad idea. What if two libraries want to use different, incompatible

[Python-ideas] Re: Native support for units [was: custom literals]

2022-04-04 Thread Greg Ewing
On 4/04/22 9:45 am, Ethan Furman wrote: Well, if we're spit-balling ideas, what about:     63_lbs    77_km/hr I'm not convinced there's a need for new syntax here. 63*lbs 77*km/hr With appropriate definitions of lbs, km and hr these can be made to construct numbers with attached

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-04 Thread Greg Ewing
On 4/04/22 9:35 am, malmiteria wrote: And just to make it clear, I am not under the impression super can only target one class. What i'm saying here is that it is the most common impression the average developper would have. How do you know this? Have you undertaken a survey of randomly

[Python-ideas] Re: mro and super don't feel so pythonic

2022-04-04 Thread Greg Ewing
On 4/04/22 9:12 am, malmiteria wrote: So, allow me to make it clear, I do get its value. Its value appears in the other use cases i account for, and wanna provide dedicated features for. (before getting rid of super and MRO's ability to provide those use case). So, if I understand correctly:

[Python-ideas] Re: Add a replace method to tuples

2022-03-14 Thread Greg Ewing
On 15/03/22 6:14 am, wfdc via Python-ideas wrote: The whole *point* is that namedtuples let you use *named fields* rather than indices. That's the point. That's the purpose. I would say the point of namedtuple is to let you use either field names or indices, whichever makes the most sense for

[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-09 Thread Greg Ewing
On 8/03/22 12:32 pm, Chris Angelico wrote: All I can see is that changes get proposed on typing-sig and actually make it into the language, but changes that get proposed on python-ideas are invariably shot down in flames, Typing is an area of Python that is under active development, so it is

[Python-ideas] Re: Syntax proposal of for..in..if in regular for loops

2022-03-03 Thread Greg Ewing
On 3/03/22 9:50 pm, Steven D'Aprano wrote: While you can put the block on the same line as the colon using semicolons: if condition: print(1); print(2) # Legal. and there's nothing to stop you from making arbitrarily long lines using this feature... if condition: print(1);

[Python-ideas] Re: repeat until

2022-03-01 Thread Greg Ewing
On Wed, 2 Mar 2022 at 09:58, Rob Cliffe via Python-ideas wrote: Without testing, I am sure it would be slower. Does that mean if you do test it, it'll be faster? :-) -- Greg ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe

[Python-ideas] Re: repeat until

2022-03-01 Thread Greg Ewing
On 2/03/22 12:50 pm, Rob Cliffe via Python-ideas wrote: As I see it, the original meaning of an exception (in whatever language) is "something unexpected has happened" or "something has gone wrong". Using exceptions for flow control has always been acceptable in Python. The iterator protocol

[Python-ideas] Re: Allowing non-ASCII bracket and quote characters in source code

2022-01-20 Thread Greg Ewing
On 20/01/22 12:52 pm, Christopher Barker wrote: On Wed, Jan 19, 2022 at 2:12 PM Greg Ewing <mailto:greg.ew...@canterbury.ac.nz>> wrote: Those particular brackets are really confusing because they're half square and half round. And THAT is why this is a bad idea. It doe

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-20 Thread Greg Ewing
On 20/01/22 3:17 am, Joao S. O. Bueno wrote: But upon seeing a method call, we can just think first of a runtime behavior Correctly, btw. Any optimization there would be an exception, that people would have to know by heart. Frozensets are immutable, so nobody should be making any

[Python-ideas] Re: Allowing non-ASCII bracket and quote characters in source code

2022-01-19 Thread Greg Ewing
On 20/01/22 3:45 am, Alexandre Brault wrote: On 2022-01-18 6:12 p.m., Chris Angelico wrote: 3) Optional semantic difference: 【1, 2, 3】 is exactly the same as (1, 2, 3), but 【1, 2, 3) would be an error. What does it say about the viability of this idea that until the second part of that

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-18 Thread Greg Ewing
On 19/01/22 6:41 am, Rob Cliffe via Python-ideas wrote: I'm happy with the     f{ ... } Fine with me too. I'd also be happy with making frozenset a keyword. It's hard to imagine it breaking any existing code, it avoids having to make any syntax changes, and all current uses of frozenset() on

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-18 Thread Greg Ewing
On 19/01/22 6:41 am, Rob Cliffe via Python-ideas wrote: I'm happy with the     f{ ... } Fine with me too. I'd also be happy with making frozenset a keyword. It's hard to imagine it breaking any existing code, it avoids having to make any syntax changes, and all current uses of frozenset() on

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-16 Thread Greg Ewing
U+2744 Snowflake, anyone? my_frozenset = ❄{1, 2, 3} -- Greg ___ 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/python-ideas.python.org/ Message

[Python-ideas] Re: inline Python functions and methods

2021-12-11 Thread Greg Ewing
On 11/12/21 5:40 pm, TobiasHT wrote: > The right function to perform inlining on shall be determined at runtime and cached in the same scope as where it’s performing it’s operations from cases where the program performs large iterations or even in infinite loops and other cases that need

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

2021-12-11 Thread Greg Ewing
On 11/12/21 1:22 pm, Christopher Barker wrote: Darn — the P and A are swapped there. "Argument" and "actual" both start with "A" -- does that help? -- Greg ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: Runtime-accessible attribute docstrings – take 2

2021-12-08 Thread Greg Ewing
On 9/12/21 12:50 am, tmkehrenb...@gmail.com wrote: The main criticism, I think, was that it is weird to have the docstring *below* the attribute. I don't think that's a problem. The docstring of a class or function is also below the name of the class or function. I think it's actually more

[Python-ideas] Re: inline Python functions and methods

2021-12-08 Thread Greg Ewing
On 9/12/21 2:07 am, TobiasHT wrote: If a function fails to be inlined at compiletime due to dynamic behavior of python, then the normal function call behavior can be the fallback The problem is that the compiler might *think* it knows where the module is at compile time, but at run time it

[Python-ideas] Re: inline Python functions and methods

2021-12-08 Thread Greg Ewing
On 9/12/21 12:03 am, Steven D'Aprano wrote: does that mean that the compiler will translate the above to: def eggs(a, b, c): def spam(*args): # Do something with args... thing = spam(a, b, c) ... If that's what's intended, it wouldn't really be an

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

2021-12-01 Thread Greg Ewing
On 2/12/21 4:40 am, Paul Moore wrote: the intended use is that people must supply a list[int] or not supply the argument *at all*. I don't think this is a style of API that we should be encouraging people to create, because it results in things that are very awkward to wrap. -- Greg

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-26 Thread Greg Ewing
On 27/11/21 11:34 am, Eric V. Smith wrote: Would adding something to the Iterator ABC really also add it to my class Foo? No, your class would need changing to inherit from the Iterator ABC. This is a big problem in general with "just add it to the ABC" ideas. A huge number of existing

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-22 Thread Greg Ewing
On 23/11/21 3:15 am, Remy wrote: Iterators to implement 'transformational' functions like map, filter, flat_map, 'reductional' functions like reduce, sum, join, and 'evaluate' functions like to_list and to_set. This would place a burden on all iterators to implement a large and complex

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-11-01 Thread Greg Ewing
On 1/11/21 4:59 am, David Mertz, Ph.D. wrote:     b = b I don't want to live in a universe where this could be anything other than a no-op in Python. -- Greg ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: Invalidate list iterators after size changes?

2021-10-09 Thread Greg Ewing
On 9/10/21 11:24 am, Tyler Hou via Python-ideas wrote: Right now, the following code is valid in Python 3.9 (and infinitely loops): ``` lst = [1, 2, 3] for i in lst: lst.append(i) ``` 1. If the size of a list, set, or dict changes, invalidate all existing iterators to that containers.

[Python-ideas] Re: Context manager for csv module 'reader' and 'DictReader'?

2021-09-06 Thread Greg Ewing
On 7/09/21 5:46 am, C. Titus Brown via Python-ideas wrote: Maybe Greg missed that DictReader.open didn’t exist and was in fact what I was asking for! Sorry about that, I thought you were asking for context manager methods to be added to an existing file-like object. If csv.DictReader had a

[Python-ideas] Re: Context manager for csv module 'reader' and 'DictReader'?

2021-09-05 Thread Greg Ewing
On 6/09/21 3:07 am, C. Titus Brown via Python-ideas wrote: with csv.DictReader.open(filename) as r: for row in r: … You can do this now: from contextlib import closing with closing(csv.DictReader.open(filename)) as r: ... IMO this is preferable than going around adding context

[Python-ideas] Re: Add a special TypeError subclass for implementation errors

2021-09-03 Thread Greg Ewing
On 4/09/21 4:32 am, Guido van Rossum wrote: The question is, would anyone ever want to make a distinction between the two in *real* code? Another problem with this idea is that there isn't just one user and one author. Library code often calls other library code written by a different author,

[Python-ideas] Re: Complete recursive pickle dump

2021-08-27 Thread Greg Ewing
On 27/08/21 11:27 pm, Evan Greenup via Python-ideas wrote: If it contains function it will persist all its attribute, and code object. For example, if user pickle recursively dump a numpy ndarray into a pickle file, when user pickle load this file from a system which doesn't install numpy,

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-07-05 Thread Greg Ewing
On 6/07/21 9:56 am, Jim Baker wrote: d = deferred_tag"Some expr: {:(x*2)}" All that is happening here is that this being wrapped in a lambda, which captures any scope lexically as usual. Is there reason to think this will be a common enough requirement to justify having an abbreviated

[Python-ideas] Re: Pre PEP: Python Literals (was custom strings before)

2021-07-05 Thread Greg Ewing
On 6/07/21 8:39 am, Guido van Rossum wrote: FWIW, we could make f-strings properly nest  too... So this is not an argument for backticks. An argument might be that single and double quotes currently do not nest and never have done, so having them start to nest but only in the context of

[Python-ideas] Re: Flatten function (was: Deprecate sum of lists)

2021-06-20 Thread Greg Ewing
On 21/06/21 6:04 am, Sebastian Berg wrote: * `flatten()` (alwasy copy) * `ravel()` (copies if needed, and additionally ensures contiguity) * `reshape(-1)` (copies if needed) They are all subtly different, unfortunately. There's also a .flat attribute, that returns a 1-d iterator! -- Greg

[Python-ideas] Re: Python Idea - extension of 'with'

2021-04-08 Thread Greg Ewing
On 9/04/21 2:59 am, anthony.flury via Python-ideas wrote: I was wondering whether a worthwhile extension might be to allow the `with` statement to have an `except` and `else` clauses I don't think I would find this very useful. My application-level exception handling is rarely that close to

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Greg Ewing
On 4/04/21 6:50 am, Chris Angelico wrote: Algebra gives us a HIGHLY compact notation (far too compact to be truly useful in computing, as it's very blackboard/paper oriented) Anyone up for allowing Mathjax in Python source? -- Greg ___ Python-ideas

[Python-ideas] Re: Reverse polish notation

2021-04-03 Thread Greg Ewing
On 3/04/21 6:15 pm, David Mertz wrote: It's a long time ago, but I'm pretty sure I used ticker tape adding machines with a big ENTER button to separate numbers... Then the operation, usually +, at the end. That seems unlikely. If you don't tell it what to do with the numbers until the very

[Python-ideas] Re: Reverse polish notation

2021-04-02 Thread Greg Ewing
On 3/04/21 5:07 pm, John wrote: This fails when it's like b*((x*2^(3-a))-(7*c)), since you now have to look back and forth and get a handle on what each of the terms is. b x 2 3 a - ** * 7 c * - * is pretty much a set of steps (3 - a, raise 2 to that, multiply x by that, multiply 7 by c and

[Python-ideas] Re: Reverse polish notation

2021-04-02 Thread Greg Ewing
On 3/04/21 4:33 pm, David Mertz wrote: add all these 20 receipts together without needing 19 "+" signs, but just one at the end. Um, that's not the way any RPN calculator I've seen works. You still need to press the "+" key 19 times, just in slightly different places. To get by with just one

[Python-ideas] Re: Reverse polish notation

2021-04-02 Thread Greg Ewing
On 3/04/21 3:51 pm, John wrote: Can't argue that long equations are hard to read. The question is which is harder. A slew of parenthesis makes a mess that's difficult to detangle. In my experience, RPN is always harder to read than infix. A slew of parens can be confusing, but a bunch of

[Python-ideas] Re: Suggesting feature for python - Big Set, Big Dictionary

2021-03-23 Thread Greg Ewing
On 24/03/21 7:47 am, Chris Angelico wrote: On Wed, Mar 24, 2021 at 5:35 AM Vijay Patel wrote: > Suggestion: 1. Big Set, Big Dictionary - > How would it be stored on disk? Would it be in some sort of database? If so, check out a database access module Also remember that virtual memory is a

[Python-ideas] Re: Multiple dispatch transpilation

2021-03-16 Thread Greg Ewing
On 17/03/21 2:54 am, Marvin van Aalst wrote: it should in principle be possible to transform the code from |Class.method|to |method(class:type)|, *before compilation*essentially allowing the same optimizations. I don't think this transformation would help with anything. If the static

[Python-ideas] Re: allow initial comma

2021-03-12 Thread Greg Ewing
On 13/03/21 5:02 am, Ned Batchelder wrote: I think the only reason anyone ever used leading commas to begin with was because of languages that didn't allow a final trailing comma.  In those worlds, to keep the editing smooth, people moved the commas to the beginning of the line, Which

[Python-ideas] Re: Integer concatenation to byte string

2021-03-02 Thread Greg Ewing
On 2/03/21 7:01 am, mmax42...@gmail.com wrote: Currently, the only way to concatenate an integer to a bytes object is by converting the integer to bytes with a function call before concatenating. No, it's not: >>> b = bytearray() >>> b.append(42) >>> b bytearray(b'*') -- Greg

[Python-ideas] Re: Alternate lambda syntax

2021-02-18 Thread Greg Ewing
On 19/02/21 9:43 am, Steven D'Aprano wrote: Although I have heard from Ruby enthusiasts that the ability to write large, complex, multi-statement anonymous block functions is really useful, its not something I can personally say I have missed. Ruby may be somewhat different here, because

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread Greg Ewing
On 18/02/21 3:38 am, MRAB wrote: So a "byte" is part of a word (a word contains multiple characters). In the Burroughs B6900 architecture, programs consisted of 48-bit words broken up into 8-bit opcodes called "syllables". -- Greg ___ Python-ideas

[Python-ideas] Re: SimpleNamespace vs object

2021-02-17 Thread Greg Ewing
On 18/02/21 3:51 am, Ricky Teachey wrote: I would personally love for SimpleNamespace to get a shorter name and become a built-in. It is a fantastic object to use in all kinds of situations I find myself disagreeing with that. It's dead simple to define your own blank-object class, and you

[Python-ideas] Re: Alternate lambda syntax

2021-02-16 Thread Greg Ewing
On 17/02/21 7:10 am, Steven D'Aprano wrote: Its no more "magic" than tuple, deque, iterator, coroutine, ordinal, modulus, etc, not to mention those ordinary English words with specialised jargon meanings like float, tab, zip, thread, key, promise, trampoline, tree, hash etc. Actually, I think

[Python-ideas] Re: Alternate lambda syntax

2021-02-16 Thread Greg Ewing
On 17/02/21 7:10 am, Steven D'Aprano wrote: "It's Greek letter, like pi that you may remember from maths class. In some technical computer science, the Greek L, lambda, is used as the symbol for functions." The most accurate answer seems to be "Because somebody made a mistake transcribing a

  1   2   3   4   5   6   7   8   9   >