sre_constants MODIFIED CLASS - ERROR

Chris Angelico rosuav at gmail.com
Fri Jun 24 04:48:25 EDT 2022


‪On Fri, 24 Jun 2022 at 18:43, ‫נתי שטרן‬‎ <nsh531 at gmail.com> wrote:‬
>
> class _NamedIntConstant(int):
>     def __new__(cls, value, name):
>         self = super(_NamedIntConstant, cls).__new__(cls, value)
>         self.name = name
>         return self
>
>     def __repr__(self):
>         return self.name
>
>     __reduce__ = None
>  MAXREPEAT = _NamedIntConstant(32,name=str(32))
>
> what's the problem with the code????

You ripped a bunch of code from the standard library without
understanding what it does, and now it doesn't work. The problem is
more with your methodology than your code.

Why are you doing this? Why not simply use what's there?

If you REALLY need to make source-level changes, make *changes*, don't
try to lift small parts out. Also, you will need to spend some hours
getting to know the code that you're mutating.

Is there an alternative newsgroup for
lazy-python-users-who-dont-want-to-do-the-work at groups.google.com ?

ChrisA


More information about the Python-list mailing list