-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 None
lst = [1, 4, 8, 3, 2, 9]
lst .= sort(). # lst is None now
2. Return something of an entirely different type, often some some kind of
summary of the original object.
For example, even with a string:
haystack = "XFGHXDEXAWR"
numX = haystack.count("X")
Under the proposal, the following would be legal, but suffer awful code
smell:
haystack .= count("X")
The suggested syntax would be a bug magnet far more often than it would be
useful.
On Wed, Sep 30, 2020, 5:45 AM Jonatan <[email protected]> wrote:
> 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
> con = "some text here"
> con = con.replace("here", "there")
>
> we could do
>
> con = "some text here"
> con .= replace("here", "there")
>
>
> Please let me know what do you think about it, Jonatan
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/QAU3URTLBVZDQA7TWECUXCG6FENRR7VZ/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/PV3X3XCNKKXSH3O67GJSOZJ3YKSCWJ2F/
Code of Conduct: http://python.org/psf/codeofconduct/