[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread MRAB
On 2021-01-23 10:11, Chris Angelico wrote: [snip] Okay. If the goal is to make UTF-8 the default, may I request that PEP 597 say so, please? With a heading of "deprecation", it's not really clear what its actual goal is. From the sound of things - and it's still possible I'm misreading PEP 59

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread MRAB
On 2021-01-24 01:14, Guido van Rossum wrote: I have definitely seen BOMs written by Notepad on Windows 10. Why can’t the future be that open() in text mode guesses the encoding? "In the face of ambiguity, refuse the temptation to guess." ___ Python-i

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-24 Thread MRAB
On 2021-01-24 17:04, Chris Angelico wrote: On Mon, Jan 25, 2021 at 3:55 AM Stephen J. Turnbull wrote: Chris Angelico writes: > Right, but as long as there's only one system encoding, that's not > our problem. If you're on a Greek system and you want to decode > ISO-8859-9 text, you have to

[Python-ideas] Re: Conditional with statements

2021-02-06 Thread MRAB
On 2021-02-07 00:57, Jonathan Crall wrote: [snip] To be clear, in the proposed syntax:     if [condition] with [obj]:         [code] Would behave exactly as:     if [condition]:         with [obj]:             [code] Is there any chance that this conditional context manager syntax mi

[Python-ideas] Re: Alternate lambda syntax

2021-02-17 Thread MRAB
On 2021-02-17 05:57, Steven D'Aprano wrote: On Wed, Feb 17, 2021 at 11:13:08AM +1300, Greg Ewing wrote: 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 symbo

[Python-ideas] Re: Reverse polish notation

2021-04-02 Thread MRAB
On 2021-04-02 16:55, Richard Damon wrote: I think python only has 3 unary operations, + - and ~ and only + and - can also be binary operations. unary + has less uses, since it normally just passes its argument, if valid, unchanged, but can be used to validate that its argument has the right type

[Python-ideas] Re: Add a mechanism so that multiple exceptions can be caught using `except E1, E2, E3:`

2021-05-09 Thread MRAB
On 2021-05-09 21:11, Bruce Leban wrote: On Sun, May 9, 2021 at 9:48 AM Thomas Grainger > wrote: now that python2.7 is EOL, it might be worth resurrecting this syntax as discussed in https://www.python.org/dev/peps/pep-3100/#id13

[Python-ideas] Re: dict.get_deep()

2021-05-23 Thread MRAB
On 2021-05-23 13:37, Marco Sulla wrote: I propose to add a get_deep(*args, default=_sentinel) method to dict. It can accept a single argument, that must be an iterable, or multiple arguments. The first element must be a key of the dict. If there's not a second element, the value is returned. If

[Python-ideas] Re: Introduce constants in Python (constant name binding)

2021-05-26 Thread MRAB
On 2021-05-26 13:53, Shreyan Avigyan wrote: I've already given one. Since Python is dynamically typed changing a critical variable can cause huge instability. Want a demonstration? Here we go, import sys sys.stdout = None Now what? Now how can we print anything? Isn't this a bug? There are lot

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread MRAB
On 2021-05-27 10:39, Shreyan Avigyan wrote: Well sometimes we don't want to pollute the module namespace. Two functions can have two variables with the same name but with different values that we want to be static. And this functionality already exists in Python but as a *hack*. This idea prop

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread MRAB
On 2021-05-27 17:44, Shreyan Avigyan wrote: My proposal is somewhat the sum of all of your ideas. Well I propose there should a STORE_STATIC_FAST opcode that stores a static variable. Static variable will be declared only once and will be initialized to None (statement syntax will be similar t

[Python-ideas] Re: Add static variable storage in functions

2021-05-27 Thread MRAB
On 2021-05-27 21:02, Brendan Barnwell wrote: On 2021-05-27 12:33, Chris Angelico wrote: With statics, you could write it like this: def merge_shortest(things): static len=len ... Simple. Easy. Reliable. (And this usage would work with pretty much any of the defined semantics.) There'

[Python-ideas] Re: The name Ellipsis should be a constant

2021-05-31 Thread MRAB
On 2021-05-31 15:55, Paul Bryan wrote: If you're proposing prevention of monkey patching Ellipsis, I think you'll have to go all-in on all builtins. For example: str = int str str == int True If you rebind str to int, the repr of str will say , so you can tell that something's ha

[Python-ideas] Re: The name Ellipsis should be a constant

2021-05-31 Thread MRAB
On 2021-05-31 21:19, Serhiy Storchaka wrote: 31.05.21 22:46, Chris Angelico пише: Originally, the notation "..." could only be used inside a subscript, and anywhere else, you'd have to spell it "Ellipsis". Now that you can use "..." anywhere, would it be worth switching the repr to just be that?

[Python-ideas] Re: Deprecate sum of lists

2021-06-16 Thread MRAB
On 2021-06-17 00:57, Chris Angelico wrote: On Thu, Jun 17, 2021 at 9:46 AM Oliver Margetts wrote: > I'm not sure why it doesn't special-case it to "".join() One reason might be because you'd have to read the entire iterator to know if it really was only strings. So there are concerns with gen

[Python-ideas] Re: Default List .get Method

2021-07-06 Thread MRAB
On 2021-07-06 02:52, Austin Graham wrote: I'm a lurker on this list and wanted to submit my own idea. It's a feature I've been wanting in Python for a while, and I have a simple implementation for it for personal use at the moment. Wanted to get feedback before I move forward. Essentially, I

[Python-ideas] Re: Default List .get Method

2021-07-06 Thread MRAB
On 2021-07-07 01:36, Steven D'Aprano wrote: On Tue, Jul 06, 2021 at 02:54:32PM +0100, MRAB wrote: This has been discussed before, most recently on 2021-06-05, but also in August 2020, and in 2017. Hi MRAB, Thanks for looking those up, but you don't happen to have URLs do you? O

[Python-ideas] Re: writelines2?

2021-07-13 Thread MRAB
On 2021-07-13 15:11, sandhoners...@gmail.com wrote: Maybe (to be consistent with other functions like print), end= since that would allow even custom line endings I'm not sure about the name 'end'. The 'print' function has 'end', but it's printed only at the end(!); .writelines would write it

[Python-ideas] Re: writelines2?

2021-07-13 Thread MRAB
On 2021-07-13 15:18, Eric V. Smith wrote: On 7/13/2021 9:52 AM, Thomas Güttler wrote: Am Di., 13. Juli 2021 um 15:02 Uhr schrieb >: Right now, writelines is a very big misnomer to many python developers, especially beginners who would expect writelines

[Python-ideas] Re: builtins for running context managers

2021-07-16 Thread MRAB
On 2021-07-16 12:44, Stephen J. Turnbull wrote: Thomas Grainger writes: > Another example, is a cash point (ATM) won't give you your money > until you take your card That ATM is effective in enforcing the desired behavior. In Python you would usually use an exception to force handling. Re

[Python-ideas] Re: Definition of a starred expression in the Language Reference

2021-08-22 Thread MRAB
On 2021-08-22 11:51, Matsuoka Takuo wrote: Dear developers, According to the Language Reference, a starred expression is defined by starred_expression ::= expression | (starred_item ",")* [starred_item] https://docs.python.org/3/reference/expressions.html#expression-lists However, in view

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-22 Thread MRAB
On 2021-08-22 17:36, Thomas Grainger wrote: bool((len(collection) == 0) is True) == True and issubclass(True, bool) 'True' is a reserved word, so you don't need to check it. However, 'bool' might have been overridden, so: __builtins__.bool((len(collection) == 0) is True) == True Come to thin

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-22 Thread MRAB
en to stop: len(collection) == 0 (len(collection) == 0) is True ((len(collection) == 0) is True) is True (((len(collection) == 0) is True) is True) is True len(collection) == 0) is True) is True)) is True # ... *wink* MRAB and Ricky: `__builtins__` is a CPython impl

[Python-ideas] Re: We should have an explicit concept of emptiness for collections

2021-08-24 Thread MRAB
On 2021-08-25 00:48, Guido van Rossum wrote: Hi Tim, I'm sorry if this has been brought up before, but *aside from PEP 8* is there anything wrong with using "if len(a)" for nonempty, or "if not len(a)" for empty? What is the cost of 'len'? If it's always O(1), then it's not a problem, but i

[Python-ideas] Re: NAN handling in statistics functions

2021-08-29 Thread MRAB
On 2021-08-30 04:31, Steven D'Aprano wrote: On Sun, Aug 29, 2021 at 08:20:07PM -0400, tritium-l...@sdamon.com wrote: Not to go off on too much of a tangent, but isn't NaN unorderable? Its greater than nothing, and less than nothing, so you can't even really sort a list with a NaN value in it (

[Python-ideas] Re: Allow starred expressions to be used as subscripts for nested lookups for getitem and setitem

2021-09-01 Thread MRAB
On 2021-09-01 17:41, Kevin Mills wrote: Given code like this: ``` d = {1: {2: {3: 4}}} print(d[1][2][3]) d[1][2][3] = None print(d) ``` It should be possible to rewrite it using a starred expression, like this: ``` d = {1: {2: {3: 4}}} keys= 1,2,3 print(d[*keys]) d[*keys] = None print(d) ```

[Python-ideas] Re: Different exceptions for assert

2021-09-09 Thread MRAB
On 2021-09-09 22:31, Juancarlo Añez wrote: Well, if the idea makes sense, then I'm certain that we'll have a very long and productive discussion about the best syntax here (re: *:=*). ;-) For backwards compatibility and no surprises: *assert: *ExType, cond, args It doesn't break anythi

[Python-ideas] Re: Shorthand syntax for lambda functions that have a single parameter

2021-09-29 Thread MRAB
On 2021-09-29 10:11, Dominik Vilsmeier wrote: Lambda functions that have a single parameter are a common thing, e.g. for "key" functions: `sorted(items, key=lambda x: x['key'])`. For these cases however, the rather long word "lambda" together with the repetition of the parameter name, results i

[Python-ideas] Re: Shorthand syntax for lambda functions that have a single parameter

2021-09-30 Thread MRAB
On 2021-09-30 07:21, Chris Angelico wrote: On Thu, Sep 30, 2021 at 4:19 PM Steven D'Aprano wrote: On Wed, Sep 29, 2021 at 02:09:03PM -0700, Guido van Rossum wrote: > Over in typing-sig we're considering a new syntax for callable *types*, > which would look like (int, int, str) -> float. A matc

[Python-ideas] Re: Shorthand syntax for lambda functions that have a single parameter

2021-10-02 Thread MRAB
es are optional if there's only one parameter, so:     () => ...     (x) => ... or x => ...     (x, y) => ...     (x, y, z) => ... etc. > On 30 Sep 2021, at 7:53 PM, MRAB wrote: > > On 2021-09-30 07:21, Chris Angelico wrote: >>> On Thu, Se

[Python-ideas] Re: Allow regex group name redefinitions

2021-10-02 Thread MRAB
On 2021-10-02 10:27, ven...@razdva.cz wrote: Hello everybody, I've got a suggestion for the std. re module developers: to consider allowing match group name redefinitions, especially in alternatives. [snip] FYI, the regex module on PyPI supports that. __

[Python-ideas] Re: Overloading unary plus in strings with "ord"

2021-10-12 Thread MRAB
On 2021-10-12 13:25, Jeremiah Vivian wrote: -1. It's unnecessary optimization for an uncommon case, abuse of syntax Good point. But what else can the unary positive do? I'm just trying to add a use for it. illogical - why should +"a" be the integer 97? Because `ord("a")` is `97`. Have you rea

[Python-ideas] Re: Overloading unary plus in strings with "ord"

2021-10-12 Thread MRAB
On 2021-10-12 13:36, Chris Angelico wrote: On Tue, Oct 12, 2021 at 11:27 PM Jeremiah Vivian wrote: > -1. It's unnecessary optimization for an uncommon case, abuse of syntax Good point. But what else can the unary positive do? I'm just trying to add a use for it. > illogical - why should +"a"

[Python-ideas] Re: Overloading unary plus in strings with "ord"

2021-10-12 Thread MRAB
On 2021-10-12 13:49, Steven D'Aprano wrote: On Tue, Oct 12, 2021 at 11:36:42PM +1100, Chris Angelico wrote: You haven't given any reason why unary plus should imply ord(). I think the question Chris is really asking is why should unary plus return ord() rather than any other function or metho

[Python-ideas] Re: Overloading unary plus in strings with "ord"

2021-10-12 Thread MRAB
On 2021-10-12 23:57, Steven D'Aprano wrote: On Wed, Oct 13, 2021 at 09:22:09AM +1100, Chris Angelico wrote: Mathematicians and programmers both extend operators to new meanings, but only where it makes sense. In fairness, mathematicians typically just invent new symbols, when they're not repu

[Python-ideas] Re: Implementing additional string operators

2021-10-13 Thread MRAB
On 2021-10-13 16:26, Marc-Andre Lemburg wrote: On 13.10.2021 17:11, Guido van Rossum wrote: Maybe we should only accept operators as aliases for existing methods. x-y could mean x.removesuffix(y) That was the idea, yes, in particular to make it similar to "+", which adds to the end of the str

[Python-ideas] Re: Unpacking in tuple/list/set/dict comprehensions

2021-10-16 Thread MRAB
On 2021-10-16 20:31, Erik Demaine wrote: On Sun, 17 Oct 2021, Steven D'Aprano wrote: On Sat, Oct 16, 2021 at 11:42:49AM -0400, Erik Demaine wrote: I guess the question is whether to define `(*it for it in its)` to mean tuple or generator comprehension or nothing at all. I don't see why that

[Python-ideas] Re: Real Positional Arguments or OO Currying

2021-10-18 Thread MRAB
On 2021-10-18 11:20, Mathew Elman wrote: I don't know if this has been suggested before, or if this is outlandishly impossible (though I would be surprised if it was), so apologies in advance if so. I have on occasion come across a situation where I use/write a signature like this: def

[Python-ideas] Re: Real Positional Arguments or OO Currying

2021-10-18 Thread MRAB
On 2021-10-18 15:58, Steven D'Aprano wrote: On Mon, Oct 18, 2021 at 10:20:17AM -, Mathew Elman wrote: despite a driving idea of python syntax being readability in english, the function signature is distinctly not english. Python's syntax was not really modelled on English, as far as I can

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults -- choice of -> vs @

2021-11-03 Thread MRAB
On 2021-11-03 18:14, Ethan Furman wrote: On 11/3/21 10:35 AM, Steven D'Aprano wrote: > I suppose that we could even add yet another overloaded meaning on the > asterix: > > # with no default, * keeps the old meaning of collecting > # extra positional values > > *para

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

2021-12-08 Thread MRAB
On 2021-12-08 23:39, Chris Angelico wrote: On Thu, Dec 9, 2021 at 10:35 AM Paul Moore wrote: On Wed, 8 Dec 2021 at 23:18, Chris Angelico wrote: > Part of the problem is that it is really REALLY hard to figure out > what the actual objections are. I asked, and the one clear answer I > got was

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

2021-12-12 Thread MRAB
On 2021-12-12 23:49, Steven D'Aprano wrote: On Sun, Dec 12, 2021 at 12:07:30PM -0700, Carl Meyer wrote: I don't think this is a fair dismissal of the concern. Taken broadly, function "wrapping" is extremely common, in the sense that what many (most?) functions do is call other functions, and th

[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-21 Thread MRAB
On 2021-12-22 01:53, Rob Cliffe via Python-ideas wrote: Currently list.remove raises ValueError if the element is not in the list. When called with the count argument, should it raise ValueError if there are fewer than `count` occurrences of the element in the list? There's str.replace and str.s

[Python-ideas] Re: Add a `count` argument to `list.remove`

2021-12-25 Thread MRAB
On 2021-12-25 23:52, Steven D'Aprano wrote: On Thu, Dec 23, 2021 at 05:53:46PM -, Stefan Pochmann wrote: Chris Angelico wrote: > If you're removing multiple, it's usually best to filter. This is a > great opportunity to learn about list comprehensions and the > difference between O(n) and O(

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

2022-01-16 Thread MRAB
On 2022-01-16 08:27, Steven D'Aprano wrote: [snip] dis.dis("frozenset({1, 2, 3})") 1 0 LOAD_NAME0 (frozenset) 2 BUILD_SET0 4 LOAD_CONST 0 (frozenset({1, 2, 3})) 6 SET_UPDATE 1

[Python-ideas] Shouldn't 'input' prompt be going to stderr?

2022-01-16 Thread MRAB
There was a discussion on another forum that mentioned the 'input' function, and it made me wonder whether 'input' should be printing the prompt to stderr instead of stdout. The convention is for normal output to go to stdout and error messages to go to stderr, so if a program needs to ask the

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

2022-01-16 Thread MRAB
On 2022-01-17 01:36, Steven D'Aprano wrote: On Sun, Jan 16, 2022 at 04:23:47PM -0800, Brendan Barnwell wrote: On 2022-01-16 16:11, Steven D'Aprano wrote: >Do they? How are they different? You have a start delimiter and an end >delimiter. > [snip] Hell, even if your argument is just "Nope, I j

[Python-ideas] Re: Shouldn't 'input' prompt be going to stderr?

2022-01-16 Thread MRAB
On 2022-01-17 03:11, Cameron Simpson wrote: On 16Jan2022 20:57, MRAB wrote: There was a discussion on another forum that mentioned the 'input' function, and it made me wonder whether 'input' should be printing the prompt to stderr instead of stdout. The convention is for

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

2022-01-17 Thread MRAB
On 2022-01-17 06:07, Greg Ewing wrote: U+2744 Snowflake, anyone? my_frozenset = ❄{1, 2, 3} That makes me think about using '@': my_frozenset = @{1, 2, 3} It's currently used as a prefix for decorators, but that's at the start of a line. It could be a problem for the REPL, though: >>>

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

2022-01-18 Thread MRAB
On 2022-01-18 18:54, Neil Girdhar wrote: Even if f{1} creates a frozenset, I don't think f{} should create a frozenset.  I think it makes more sense to keep f{1: 2} open for frozendict if it ever makes it in.  Also, {} should be consisten with f{} (both should create dicts).  If you want an emp

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

2022-01-18 Thread MRAB
On 2022-01-18 23:50, Steven D'Aprano wrote: On Wed, Jan 19, 2022 at 11:30:36AM +1300, Greg Ewing wrote: I'd also be happy with making frozenset a keyword. - int, float, str, tuple, dict, set, exceptions, len, etc are not keywords, so they can be shadowed (for good or bad); - alone out of

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

2022-01-18 Thread MRAB
On 2022-01-19 00:02, Steven D'Aprano wrote: On Wed, Jan 19, 2022 at 10:12:23AM +1100, Chris Angelico wrote: Not sure about Python, but C and C++ have digraphs and trigraphs as alternatives for certain symbols, specifically because some OS/keyboard/language combinations may not be able to easily

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

2022-01-20 Thread MRAB
On 2022-01-21 00:18, Cameron Simpson wrote: Well, I've just waded through this discussion. This all feels to me like a special case of "wanting a constant for bytecode". What is we had a "freeze" operator, eg: |foo| which would produce a frozen version of foo. I'm liking the vertical bar

[Python-ideas] Re: Missing expandvars equivalent in pathlib

2022-02-11 Thread MRAB
On 2022-02-11 20:05, Ricky Teachey wrote: Just had a thought kernel: what if there were an f-string mini-language directive to grab environment variables and expand user paths? That seems to me like it could be even more useful beyond just working with paths. Maybe something like: f"{my_var:

[Python-ideas] Re: Regex timeouts

2022-02-15 Thread MRAB
On 2022-02-15 06:05, Tim Peters wrote: [Steven D'Aprano ] I've been interested in the existence of SNOBOL string scanning for a long time, but I know very little about it. How does it differ from regexes, and why have programming languages pretty much standardised on regexes rather than other f

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-31 Thread MRAB
On 2018-07-31 20:53, Jonathan Fine wrote: Stephan Houben wrote: Nope, the introduction of the tmp variable changed the semantics. It isn't a "chain" anymore so it breaks shortcutting. I'm confused. Assume 'a' is not defined. With Python's dot (attribute access) we have a.b.c NameError: nam

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-08-02 Thread MRAB
On 2018-08-02 20:03, Eric Fahlgren wrote: From the PEP: > From email/generator.py (and importantly note that there is no way to substitute or for ?? in this situation): > mangle_from_ = True if policy is None else policy.mangle_from_ > After updating: > mangle_from_ = policy?.mangle_from_

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-08-02 Thread MRAB
On 2018-08-02 22:49, Eric Fahlgren wrote: On Thu, Aug 2, 2018 at 1:22 PM MRAB <mailto:pyt...@mrabarnett.plus.com>> wrote: > policy?.mangle_from_ ?? True > True (??? since lhs is None?) > No, it's not 'policy.mangle_from_' that could be None

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

2018-08-03 Thread MRAB
On 2018-08-03 23:05, Benedikt Werner wrote: There was a proposal to allow overloading boolean operators in Pep-335 [2], but that PEP was rejected for a variety of very good reasons.  I think none of those reasons (besides the conversation fizzling out) apply to my proposal. Maybe I am missing

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread MRAB
On 2018-08-13 20:08, Abe Dillon wrote: [Bruce Leban] Lambda calculus IS computer science. It's a foundation of computer science. That doesn't mean it "IS" computer science. Set theory is a foundation of computer science. It's still it's own discipline. [snip] The word "is" can mean, am

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-13 Thread MRAB
On 2018-08-14 02:46, Michael Selik wrote: On Mon, Aug 13, 2018, 5:48 PM Greg Ewing > wrote: Chris Angelico wrote: > No, lambda calculus isn't on par with brakes - but anonymous functions > are, and if they're called "lambda", you just lear

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

2018-08-15 Thread MRAB
On 2018-08-15 09:17, Jonathan Fine wrote: Steve Barnes and Greg Ewing wrote: * A dinosaur is specifically an extinct terrible (formerly considered) lizard Which technically is not a lizard. I can't resist. Puffinus puffinus is the scientific name for (drum roll) no, not the Atlantic (o

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

2018-08-15 Thread MRAB
On 2018-08-15 18:27, MRAB wrote: On 2018-08-15 09:17, Jonathan Fine wrote: Steve Barnes and Greg Ewing wrote: * A dinosaur is specifically an extinct terrible (formerly considered) lizard Which technically is not a lizard. I can't resist. Puffinus puffinus is the scientific nam

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread MRAB
On 2018-08-22 01:25, Jonathan Fine wrote: Hi Abe Summary: You've done good work here. I've skim read the 2006 discussion you found. You wrote: I'm trying to dig up past threads about alternatives to lambda because I would be astonished if "def" hadn't been considered and rejected for some rea

Re: [Python-ideas] A simple proposal concerning lambda

2018-08-21 Thread MRAB
int): x def (x: int) -> int: x On Tue, Aug 21, 2018 at 6:28 PM MRAB <mailto:pyt...@mrabarnett.plus.com>> wrote: On 2018-08-22 01:25, Jonathan Fine wrote: > Hi Abe > > Summary: You've done good work here. I've skim read the 2006 > dis

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

2018-08-22 Thread MRAB
On 2018-08-22 23:44, Greg Ewing wrote: Steven D'Aprano wrote: Not "process the sorted list", but reify the sort verb into an actual thing (an object or value) and then process that thing itself. This is mind-bending when you think about it, far more mind-blowing than the normal linguistic pro

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

2018-08-23 Thread MRAB
On 2018-08-23 03:10, Abe Dillon wrote: [Chris Angelico] Because your form cannot possibly work without some additional information. That isn't my form. That's PSEUDO CODE. Just like I wrote above it. You're the one who's not listening.  The alternative I've suggested, for the thousan

Re: [Python-ideas] A GUI for beginners and experts alike

2018-08-24 Thread MRAB
On 2018-08-24 16:27, Mike Barnett wrote: Liking the comments Paul! [snip] It has the call information about the Text widget and all the others. Is this what you mean by a Signature? Text(Text, scale=(None, None), size=(None, None), auto_size_text=None, font=None, te

Re: [Python-ideas] On evaluating features [was: Unpacking iterables for augmented assignment]

2018-08-28 Thread MRAB
On 2018-08-28 18:57, Guido van Rossum wrote: So we currently have iterable unpacking:   a, b, c = x  # x better be an iterable of exactly 3 values as well as tuple packing:   x = a, b, c  # sets x to a tuple of 3 values (a, b, c) and we can combine these, e.g.:   a, b, c = x, y, z and th

Re: [Python-ideas] Add .= as a method return value assignment operator

2018-09-27 Thread MRAB
On 2018-09-27 14:13, Calvin Spealman wrote: Absolutely -1 on this. Consider the following example: def encode(s, *args):     """Force UTF 8 no matter what!"""     return s.encode('utf8') text = "Hello, there!" text .= encode('latin1') Do you see how this creates an ambiguous situation? Impli

Re: [Python-ideas] Add closing and iteration to threading.Queue

2018-10-21 Thread MRAB
On 2018-10-21 18:58, Vladimir Filipović wrote: Hi! I originally submitted this as a pull request. Raymond Hettinger suggested it should be given a shakeout in python-ideas first. https://github.com/python/cpython/pull/10018 https://bugs.python.org/issue35034 [snip] FTR, this has been discusse

Re: [Python-ideas] Add closing and iteration to threading.Queue

2018-10-21 Thread MRAB
On 2018-10-21 22:30, Antoine Pitrou wrote: On Sun, 21 Oct 2018 19:58:05 +0200 Vladimir Filipović wrote: To anticipate a couple more possible questions: - What would this proposal do about multiple producers/consumers needing to jointly decide _when_ to close the queue? Explicitly nothing. T

Re: [Python-ideas] Add closing and iteration to threading.Queue

2018-10-23 Thread MRAB
On 2018-10-23 06:13, Nathaniel Smith wrote: On Sun, Oct 21, 2018 at 8:31 PM, Guido van Rossum wrote: On Sun, Oct 21, 2018 at 6:08 PM Nathaniel Smith wrote: I'm not sure if this is an issue the way Queue is used in practice, but in general you have to be careful with this kind of circular flow

Re: [Python-ideas] Off-topic: can't access mail.python.org

2018-10-28 Thread MRAB
On 2018-10-28 15:44, Mikhail V wrote: Sorry for posting it here on the list, but I don't know the right contact for technical questions. The problem is, for 3 weeks or so the mail.python.org site is not accessible for me. What can be causing this? This means I can't man

Re: [Python-ideas] Off-topic: can't access mail.python.org

2018-10-29 Thread MRAB
On 2018-10-29 13:56, Steven D'Aprano wrote: On Sun, Oct 28, 2018 at 06:44:22PM +0300, Mikhail V wrote: Sorry for posting it here on the list, but I don't know the right contact for technical questions. The problem is, for 3 weeks or so the mail.python.org site is not accessible for me. What can

Re: [Python-ideas] Make fnmatch.filter accept a tuple of patterns

2018-11-03 Thread MRAB
On 2018-11-03 17:45, David Mertz wrote: On Sat, Nov 3, 2018, 1:30 PM Stephen J. Turnbull wrote: P.S.   I can't resist.  This is horrible, but: def multifilter(names, *patterns):     return list(set().union(*[fnmatch.filter(names, p) for

Re: [Python-ideas] Enhancing range object string displays

2018-11-19 Thread MRAB
On 2018-11-20 00:19, Steven D'Aprano wrote: On the bug tracker, there is a proposal to enhance range objects so that printing them will display a snapshot of the values included, including the end points. For example: print(range(10)) currently displays "range(10)". The proposal is for the __st

Re: [Python-ideas] hybrid regex engine: backtracking + Thompson NFA

2018-11-25 Thread MRAB
On 2018-11-25 16:52, Celelibi wrote: Hello, I found this topic discussed on the python-dev ML back in 2010 [1]. I'm bringing it up 8 years later with a variation. In short: The article [2] highlight that backtracking-based regex engine (like SRE in python) have pathological cases that run in an

Re: [Python-ideas] Add regex pattern literal p""

2018-12-27 Thread MRAB
On 2018-12-27 11:48, Ma Lin wrote: [snip] 2, We can't use regex module as a drop-in replacement: import regex as re IMHO, I would like to see regex module be adopted into stdlib after cutting off its "full case-folding" and "fuzzy matching" features. I think that omitting full casefolding would

Re: [Python-ideas] NAN handling in the statistics module

2019-01-07 Thread MRAB
On 2019-01-07 16:34, Steven D'Aprano wrote: On Mon, Jan 07, 2019 at 10:05:19AM -0500, David Mertz wrote: [snip] It's not hard to manually check for NaNs and generate those in your own code. That is correct, but by that logic, we don't need to support *any* form of NAN handling at all. It is

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread MRAB
On 2019-01-29 23:30, Terry Reedy wrote: On 1/28/2019 8:40 PM, Jamesie Pic wrote: > 0. os.path.join takes *args Since at least 1 path is required, the signature is join(path, *paths). I presume that this is the Python version of the Unix version of the system call that it wraps.. The hidden a

Re: [Python-ideas] Add list.join() please

2019-01-29 Thread MRAB
On 2019-01-29 23:38, Greg Ewing wrote: Brendan Barnwell wrote: Personally what I find is perverse is that .join is a method of strings but does NOT call str() on the items to be joined. Neither do most other string methods: >>> s = "hovercraft" >>> s.count(42) Traceback (most recent c

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-01 Thread MRAB
On 2019-02-02 04:32, Steven D'Aprano wrote: [snip] Of course it makes sense. Even numpy supports inhomogeneous data: [snip] "inhomogeneous"? Who came up with that? "in-" is a negative prefix in Latin words, but "homogeneous" comes from Greek, where the negative prefix is "a-" (or "an-" bef

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-02 Thread MRAB
On 2019-02-02 08:58, Steven D'Aprano wrote: On Sat, Feb 02, 2019 at 05:10:14AM +0000, MRAB wrote: On 2019-02-02 04:32, Steven D'Aprano wrote: [snip] > >Of course it makes sense. Even numpy supports inhomogeneous data: > [snip] "inhomogeneous"? Who came up with tha

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-02 Thread MRAB
On 2019-02-02 09:22, Kirill Balunov wrote: сб, 2 февр. 2019 г. в 07:33, Steven D'Aprano >: I didn't say anything about a vector type. I agree  you did not say. But since you started a new thread from the one where the vector type was a little discussed, it

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-02 Thread MRAB
or its members? >>> list(my_strings) You might be wanting to convert a vector into a list: ['one', 'two', 'three'] or convert each of its members onto lists: Vector([['one'], ['two'], ['three']]) > Le sam. 2 févr. 2019 à 19:26

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-02 Thread MRAB
On 2019-02-03 01:54, David Mertz wrote: Here is a very toy proof-of-concept: >>> from vector import Vector >>> l = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split() >>> v = Vector(l) >>> v >>> v.strip().lower().replace('a','X') >>> vt = Vector(tupl

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-02 Thread MRAB
On 2019-02-03 02:03, David Mertz wrote: Slightly more on my initial behavior: >>> Vector({1:2,3:4}) TypeError: Ambiguity vectorizing a map, perhaps try it.keys(), it.values(), or it.items() >>> Vector(37) TypeError: Vector can only be initialized with an iterable >>>

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-03 Thread MRAB
On 2019-02-03 22:58, David Mertz wrote: >>> len(v)  # Number of elements in the Vector `v` Agreed, this should definitely be the behavior.  So how do we get a vector of lengths of each element? >>> # Compute the length of each element of the Vector `v` >>> v.apply(len) >>

Re: [Python-ideas] need python automation code convert MDB files into csv files.

2019-02-05 Thread MRAB
On 2019-02-05 11:42, Rhodri James wrote: On 05/02/2019 00:10, vinoth A N wrote: [snip] extension = 'mdb' result = [i for i in glob.glob('*.{}'.format(extension))] Not a bug, but you are making unnecessary work for yourself here. 'extension' is only ever the string "mdb", so why go to all the

Re: [Python-ideas] Vectorization [was Re: Add list.join() please]

2019-02-07 Thread MRAB
On 2019-02-07 05:27, Chris Angelico wrote: On Thu, Feb 7, 2019 at 4:03 PM Steven D'Aprano wrote: At the risk of causing confusion^1, we could have a "vector call" syntax: # apply len to each element of obj, instead of obj itself len[obj] which has the advantage that it only requires t

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

2019-02-27 Thread MRAB
On 2019-02-27 17:37, Guido van Rossum wrote: On Wed, Feb 27, 2019 at 9:34 AM George Castillo > wrote: The key conundrum that needs to be solved is what to do for `d1 + d2` when there are overlapping keys. I propose to make d2 win in this case, w

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

2019-03-02 Thread MRAB
On 2019-03-02 22:02, francismb wrote: On 2/27/19 7:14 PM, MRAB wrote: Are there any advantages of using '+' over '|'? or for e.g. '<=' (d1 <= d2) over '+' (d1 + d2) '<=' is for comparison, less-than-or-equal (in the case of sets,

Re: [Python-ideas] unittest: 0 tests pass means failure of the testsuite

2019-03-06 Thread MRAB
On 2019-03-06 20:12, Matěj Cepl wrote: Hi, I am a lead maintainer of Python packages in OpenSUSE and I can see the pattern of many packagers adding blindly python setup.py test to %check section of our SPEC file. The problem is that if the package doesn't use unittest (it actually uses no

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

2019-03-08 Thread MRAB
On 2019-03-08 16:55, Guido van Rossum wrote: [snip] If we were to use "|" and "&" for dict "union" and "intersection", the mutual distributive properties will hold. Since "|" (especially "|=") *is* suitable for "update", I think we should reserve "+" for some future commutative extensio

Re: [Python-ideas] Why operators are useful

2019-03-15 Thread MRAB
On 2019-03-15 19:05, Jonathan Fine wrote:> Guido wrote: > >> There's been a lot of discussion about an operator to merge two dicts. I participated in the beginning but quickly felt overwhelmed by the endless repetition, so I muted most of the threads. > >> But I have been thinking about the rea

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

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

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

2019-03-24 Thread MRAB
On 2019-03-24 08:42, Alex Grigoryev wrote: Following the discussion here I propose to add 3 new string m

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

2019-03-30 Thread MRAB
On 2019-03-30 13:03, David Mertz wrote: On Sat, Mar 30, 2019, 8:42 AM Steven D'Aprano > wrote: Most of us have had to cut a prefix or a suffix from a string, often a file extension. Its not as common as, say, stripping whitespace, but it happens often enou

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

2019-03-31 Thread MRAB
On 2019-03-31 16:48, David Mertz wrote: The only reason I would support the idea would be to allow multiple suffixes (or prefixes). Otherwise, it just does too little for a new method. But adding that capability of startswith/endswith makes the cut off something easy to get wrong and non-trivia

  1   2   3   4   >