[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread David Mertz
On Wed, Sep 30, 2020 at 7:30 PM Greg Ewing wrote: > On 1/10/20 4:25 pm, David Mertz wrote: > > In all the years I've used and taught namedtuples, I think I've never > > used the ._replace() method. The leading underscore is a hint that the > > method is "private" > > Usually that would be true,

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Greg Ewing
On 1/10/20 4:25 pm, David Mertz wrote: In all the years I've used and taught namedtuples, I think I've never used the ._replace() method.  The leading underscore is a hint that the method is "private" Usually that would be true, but namedtuple is a special case. The docs make it clear that

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Brendan Barnwell
On 2020-09-30 13:42, David Mertz wrote: -1. Fluent programming is uncommon in Python, and hence few methods return a call of the same or similar type. Methods on strings are an exception here, but they are unusual (partly because strings are immutable). This argument is mentioned a lot on

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread David Mertz
On Wed, Sep 30, 2020 at 4:24 PM Ben Rudiak-Gould wrote: > On Wed, Sep 30, 2020 at 1:43 PM David Mertz wrote: > >> Fluent programming is uncommon in Python, and hence few methods return a >> call of the same or similar type. >> > > I think that if you include built-in operators as (shorthand

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Ben Rudiak-Gould
On Wed, Sep 30, 2020 at 1:43 PM David Mertz wrote: > Fluent programming is uncommon in Python, and hence few methods return a > call of the same or similar type. > I think that if you include built-in operators as (shorthand for) method calls, and you count the number of occurrences in typical

[Python-ideas] Re: PEP 637 - support for indexing with keyword arguments (Was: Re: PEP 9999 (provisional): ...)

2020-09-30 Thread Henry F. Schreiner
I know, I was just referring to making this a standard python function with *args, **kwargs. This PEP only solves one specific problem (keyword arguments), while it seems like it would be worth while solving all of them (no arguments, tuple vs. list, and having to learn a special one-off syntax

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Bruce Leban
If I can, I want to back up the conversation a bit. Instead of starting with a solution, what's the problem? I believe the issue that this is trying to solve is that some functions that operate on an object return a new object, and we would like to use them to modify an object. Setting aside the

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread David Mertz
-1. Fluent programming is uncommon in Python, and hence few methods return a call of the same or similar type. Methods on strings are an exception here, but they are unusual (partly because strings are immutable). Methods in Python tend to do one of two things: 1. Mutate in place, returning

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Abdur-Rahmaan Janhangeer
The dot has recently been used a lot kotlin: for loop 0..9 Js: ...array .= seems cool enough Btw i saw this on Kotlin's doc, the first time i see a direct reference from one 'recent' language concerning another. Kotlin's loops are similar to Python's. for iterates over anything that is

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Marco Sulla
On Wed, 30 Sep 2020 at 20:02, Steven D'Aprano wrote: > There's also the factor that the dot operator is not very visually > distinctive. I completely agree. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Steven D'Aprano
On Thu, Oct 01, 2020 at 04:02:20AM +1000, Steven D'Aprano wrote: > Hi Konatan, welcome! Comments below. Oh I'm very sorry, that was a typo, I meant Jonatan. -- Steve ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Steven D'Aprano
Hi Konatan, welcome! Comments below. On Wed, Sep 30, 2020 at 06:41:04PM +0300, Jonatan wrote: [...] > it would be nice if you could implement also __igetattr__ or something, > which means: > > instead of > con = "some text here" > con = con.replace("here", "there") > > we could do > > con =

[Python-ideas] Re: A new suggestion for Python

2020-09-30 Thread Mike Miller
On 2020-09-30 08:41, Jonatan wrote: instead of con = "some text here" con  = con.replace("here", "there") we could do con = "some text here" con .= replace("here", "there") (Your message had some odd formatting but thankfully there was a plain-text version included without the issue.)

[Python-ideas] A new suggestion for Python

2020-09-30 Thread Jonatan
Hi, My name is Jonatan and i am programming in Python for about 4 years, I have a great idea, there are iX` methods, such as __ior__, __iadd__, __iand__ etc.., which implements the |=, +=, &= behavior, it would be nice if you could implement also __igetattr__ or something, which means: instead of

[Python-ideas] Package kwkey v0.0.2 provides items-keys duality to support PEP 637

2020-09-30 Thread Jonathan Fine
I'm pleased to announce v0.0.2 of my kwkeys package. https://pypi.org/project/kwkey/ The main new feature is items-key duality. Based on that, it emulates the semantics proposed by D'Aprano and van Rossum. It also emulates the semantics proposed by myself. What does this mean? Here, by duality I

[Python-ideas] Re: Trouble with "decorator mixins" and ABCs

2020-09-30 Thread Guido van Rossum
Would it help if ‘__abstractmethods__’ was documented, overruling whatever the PEP says? On Wed, Sep 30, 2020 at 00:01 Ben Avrahami wrote: > I encountered this problem when I needed to implement a class that defined > all 4 of the comparison operators, once with `dataclass` (for one >

[Python-ideas] Re: PEP 637 - support for indexing with keyword arguments (Was: Re: PEP 9999 (provisional): ...)

2020-09-30 Thread Sebastian Kreft
On Wed, Sep 30, 2020 at 2:44 AM Steven D'Aprano wrote: > On Sun, Sep 27, 2020 at 07:59:18AM -0300, Sebastian Kreft wrote: > > > Hi Steven, could you share some examples of what you have in mind. > Having a > > more concrete example of an API that would benefit from > mixed-subscripting > > would

[Python-ideas] Re: PEP 637 - support for indexing with keyword arguments (Was: Re: PEP 9999 (provisional): ...)

2020-09-30 Thread Stefano Borini
On Tue, 29 Sep 2020 at 22:31, wrote: > Furthermore, you currently can't tell the difference between `x[(a, b)]` and > `x[a, b]`; with the new function, libraries could differentiate, and maybe > eventually make them behave reasonably (you can always use x[*c] if you > already have a tuple,

[Python-ideas] Re: PEP 637 - support for indexing with keyword arguments (Was: Re: PEP 9999 (provisional): ...)

2020-09-30 Thread Stefano Borini
On Wed, 30 Sep 2020 at 06:44, Steven D'Aprano wrote: > matrix[3, 4] # unambiguously a cell reference > matrix[3] # ambiguous, forbidden > matrix[3, axis='row'] # unambiguously a row > matrix[3, axis='col'] # unambiguously a column I guess everybody

[Python-ideas] Re: Trouble with "decorator mixins" and ABCs

2020-09-30 Thread Ben Avrahami
I encountered this problem when I needed to implement a class that defined all 4 of the comparison operators, once with `dataclass` (for one implementation) and once with `total_order` (for another).Also, 3rd party libs are expected to fall down this rabbit hole, and unless they're expected to

[Python-ideas] Re: PEP 637 and keyword only subscripts

2020-09-30 Thread Steven D'Aprano
On Mon, Sep 28, 2020 at 08:19:01PM -0700, Ben Rudiak-Gould wrote: > Maybe a singleton that supported no useful operations, not even __eq__ or > __bool__, would be sufficiently inconvenient that it would only be used for > defaults and "is" tests for said defaults. NotImplemented is halfway