[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Dennis Sweeney
PEP 616 -- String methods to remove prefixes and suffixes is available here: https://www.python.org/dev/peps/pep-0616/ Changes: - Only accept single affixes, not tuples - Make the specification more concise - Make fewer stylistic prescriptions for usage - Fix typos A reference implementation GitH

[Python-Dev] Re: Enum._convert should change __repr__ and/or __str__ to use module name instead of class name

2020-03-27 Thread Chris Angelico
On Sat, Mar 28, 2020 at 11:28 AM Ivan Pozdeev via Python-Dev wrote: > > On 26.03.2020 19:24, Ethan Furman wrote: > > Before Enum, the repr for socket.AF_UNIX was: > > > > 1 > > > > Not very useful for debugging. > > On the contrary, it's perfect. I know everything I need: it's an integer > consta

[Python-Dev] Re: Enum._convert should change __repr__ and/or __str__ to use module name instead of class name

2020-03-27 Thread Ethan Furman
On 03/27/2020 05:21 PM, Ivan Pozdeev via Python-Dev wrote: On 26.03.2020 19:24, Ethan Furman wrote: On 03/25/2020 06:53 PM, Ivan Pozdeev via Python-Dev wrote: A diagnostic is always done by the same algorithm: 1) Identify the exact place in code where the problem manifests itself 2) Examine

[Python-Dev] Re: Enum._convert should change __repr__ and/or __str__ to use module name instead of class name

2020-03-27 Thread Kyle Stanley
Ivan Pozdeev wrote: > More information is not better if that information is harmful rather than helpful. While that argument does apply in some cases, I'd have to very much disagree that "" is harmful in comparison to just "1"; it clearly shows the value on the right side of the colon. As for the

[Python-Dev] Re: Enum._convert should change __repr__ and/or __str__ to use module name instead of class name

2020-03-27 Thread Ivan Pozdeev via Python-Dev
On 26.03.2020 19:24, Ethan Furman wrote: On 03/25/2020 06:53 PM, Ivan Pozdeev via Python-Dev wrote: A diagnostic is always done by the same algorithm: 1) Identify the exact place in code where the problem manifests itself 2) Examine the state of the program at that moment to find out which if

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Guido van Rossum
On Fri, Mar 27, 2020 at 3:29 PM Dennis Sweeney wrote: > > > One may also continue using ``startswith()`` > > > and ``endswith()`` > > > methods for control flow instead of testing the lengths as above. > > > > > > That's worse, in a sense, since "foofoobar".removeprefix("foo") returns > > "foobar

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Dennis Sweeney
> > One may also continue using ``startswith()`` > > and ``endswith()`` > > methods for control flow instead of testing the lengths as above. > > > > That's worse, in a sense, since "foofoobar".removeprefix("foo") returns > "foobar" which still starts with "foo". I meant that startswith might be

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Guido van Rossum
On Fri, Mar 27, 2020 at 1:55 PM Dennis Sweeney wrote: > I like how that would take the pressure off of the Python sample. How's > something like this? > > Specification > = > > The builtin ``str`` class will gain two new methods which will behave > as follows when ``ty

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Dennis Sweeney
I like how that would take the pressure off of the Python sample. How's something like this? Specification = The builtin ``str`` class will gain two new methods which will behave as follows when ``type(self) is str``:: def removeprefix(self: str, prefix: str,

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Guido van Rossum
How about just presenting pseudo code with the caveat that that's for the base str and bytes classes only, and then stipulating that for subclasses the return value is still a str/bytes/bytearray instance, and leaving it at that? After all the point of the Python code is to show what the C code sho

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Dennis Sweeney
I was trying to start with the the intended behavior of the str class, then move on to generalizing to other classes, because I think completing a single example and *then* generalizing is an instructional style that's easier to digest, whereas intermixing all of the examples at once can get con

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Dennis Sweeney
I appreciate the input and attention to detail! Using the ``str()`` constructor was sort of what I had thought originally, and that's why I had gone overboard with "casting" in one iteration of the sample code. When I realized that this isn't quite "casting" and that ``__str__`` can be overridd

[Python-Dev] Summary of Python tracker Issues

2020-03-27 Thread Python tracker
ACTIVITY SUMMARY (2020-03-20 - 2020-03-27) Python tracker at https://bugs.python.org/ To view or respond to any of the issues listed below, click on the issue. Do NOT respond to this message. Issues counts and deltas: open7357 ( -1) closed 44486 (+66) total 51843 (+65) Open issues wi

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread Steve Holden
On Wed, Mar 25, 2020 at 5:42 PM Dennis Sweeney wrote: > I'm removing the tuple feature from this PEP. So now, if I understand > correctly, I don't think there's disagreement about behavior, just about > how that behavior should be summarized in Python code. > [...] > return (the original obje

[Python-Dev] Re: The Python 2 death march

2020-03-27 Thread Sumana Harihareswara
Benjamin: now that PyCon 2020 has been cancelled, are you considering releasing 2.7.18 slightly earlier? -- Sumana Harihareswara Changeset Consulting https://changeset.nyc ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email

[Python-Dev] Re: sys.trace without alert or remove trace by C

2020-03-27 Thread Leandro Müller
Hello Victor. Thank you. The tips help me a lot. I think the tip needs to stay inside on document to reduce time to seach soluction. Thanks. Att. Leandro Müller De: Victor Stinner Enviado: Thursday, March 26, 2020 7:08:42 PM Para: Leandro Müller Cc: python-dev@p

[Python-Dev] Clean memory on C trace

2020-03-27 Thread Leandro Müller
Hi. I need to clean memory on function on PyEval_SetTrace. When the python code run a while test, the memory consumption goes up a lot (99% of the system). exemple: while 1 == 1: pass My trace function is simple. static map session_debug_user; char *user_console; int trace_trampoline(

[Python-Dev] Re: PEP 616 -- String methods to remove prefixes and suffixes

2020-03-27 Thread senthil
On Sun, Mar 22, 2020 at 05:00:10AM -, Dennis Sweeney wrote: > I like "removeprefix" and "removesuffix". My only concern before had > been length, but three more characters than "cut***fix" is a small > price to pay for clarity. I personally rely on auto-complete of my editor while writing. So,

[Python-Dev] C trace after start runtime

2020-03-27 Thread Leandro Müller
Hello. I need to start C trace the thread after to start, its to reduce of the time of the process. I had a lot performance changes sys.trace to C trace, but I need to reduce more time. Are there any soluction to set trace during thead runtime? Att. Leandro Müller _