how to solve this (argparse)
traceback:
Traceback (most recent call last):
File "u:\oracle\RTR.py", line 10, in <module>
class sre_constants():
File "u:\oracle\RTR.py", line 77, in sre_constants
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
Also note that while it's claimed to be fine These Days, inheriting from
a base type like this is sometimes tricky, sometimes broken... be
somewhat aware.
??? ???? wrote at 2022-6-23 15:31 +0300:
how to solve this (argparse)
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
This does not look like an `argparse` problem:
the traceback comes from `oracle/RTR.py`.
class _NamedIntConstant(int):
def __init__(cls, value):
self = super(_NamedIntConstant, cls).__init__(cls, value)
self.name = name
return self
On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer" <dieter@handshake.de> declaimed the following:
??? ???? wrote at 2022-6-23 15:31 +0300:
how to solve this (argparse)
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
This does not look like an `argparse` problem:
the traceback comes from `oracle/RTR.py`.
And the listed code looks quite suspicious to me...
class _NamedIntConstant(int):
def __init__(cls, value):
self = super(_NamedIntConstant, cls).__init__(cls, value)
self.name = name
return self
There does not appear to be any provision for keyword arguments at all. The only use of "name" is to an undefined object.
I copied code from argparse library and modified it
בתאריך יום חמישי, 23 ביוני 2022, מאת Dieter Maurer <dieter@handshake.de>:
נתי שטרן wrote at 2022-6-23 15:31 +0300:
how to solve this (argparse)
traceback:
Traceback (most recent call last):
File "u:\oracle\RTR.py", line 10, in <module>
class sre_constants():
File "u:\oracle\RTR.py", line 77, in sre_constants
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
נתי שטרן wrote at 2022-6-23 15:31 +0300:
how to solve this (argparse)
traceback:
Traceback (most recent call last):
File "u:\oracle\RTR.py", line 10, in <module>
class sre_constants():
File "u:\oracle\RTR.py", line 77, in sre_constants
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
This does not look like an `argparse` problem:
the traceback comes from `oracle/RTR.py`.
:
On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer" <dieter@handshake.de> declaimed the following:
??? ???? wrote at 2022-6-23 15:31 +0300:
how to solve this (argparse)
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
This does not look like an `argparse` problem:
the traceback comes from `oracle/RTR.py`.
And the listed code looks quite suspicious to me...
class _NamedIntConstant(int):
def __init__(cls, value):
self = super(_NamedIntConstant, cls).__init__(cls, value)
self.name = name
return self
There does not appear to be any provision for keyword arguments at all.
The only use of "name" is to an undefined object.
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.
freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list
On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer"<dieter@handshake.de> declaimed the following:
??? ???? wrote at 2022-6-23 15:31 +0300:
how to solve this (argparse)
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
This does not look like an `argparse` problem:
the traceback comes from `oracle/RTR.py`.
And the listed code looks quite suspicious to me...
class _NamedIntConstant(int):
def __init__(cls, value):
self = super(_NamedIntConstant, cls).__init__(cls, value)
self.name = name
return self
There does not appear to be any provision for keyword arguments at all. The only use of "name" is to an undefined object.
Op 24/06/2022 om 0:32 schreef Dennis Lee Bieber:
On Thu, 23 Jun 2022 18:57:31 +0200, "Dieter Maurer"<dieter@handshake.de> declaimed the following:
??? ???? wrote at 2022-6-23 15:31 +0300:
how to solve this (argparse)
MAXREPEAT = _NamedIntConstant(32,name=str(32))
TypeError: 'name' is an invalid keyword argument for int()
This does not look like an `argparse` problem:
the traceback comes from `oracle/RTR.py`.
And the listed code looks quite suspicious to me...
class _NamedIntConstant(int):
def __init__(cls, value):
self = super(_NamedIntConstant, cls).__init__(cls, value)
self.name = name
return self
There does not appear to be any provision for keyword arguments atall.
The only use of "name" is to an undefined object.
The code seems to be a copy of Lib/re/_constants.py (or
Lib/sre_constants.py before commit
1be3260a90f16aae334d993aecf7b70426f98013), but in _constants.py that
class uses __new__ instead of __init__:
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
(unless still older versions did use __init__)
It's used there as a kind of enum. I guess that code was originally
written before Python had enum.Enum. _makecodes() uses it so create
named int objects from its arguments, with automatically generated consecutive int values, places them in the global namespace (feels like
a code smell to me) and also returns them.
def _makecodes(*names):
items = [_NamedIntConstant(i, name) for i, name in
enumerate(names)]
globals().update({item.name: item for item in items})
return items
# operators
OPCODES = _makecodes(
# failure=0 success=1 (just because it looks better that way :-)
'FAILURE', 'SUCCESS',
'ANY', 'ANY_ALL',
'ASSERT', 'ASSERT_NOT',
'AT',
# ...
)
נתי שטרן, are you trying to use that semi-enum functionality? Most likely you're better of using enum.Enum instead.
--
"You can fool some of the people all the time, and all of the people some
of the time, but you cannot fool all of the people all of the time."
-- Abraham Lincoln
"You can fool too many of the people too much of the time."
-- James Thurber
--
https://mail.python.org/mailman/listinfo/python-list
Assuming: that the "value" in your init method signature was supposed to
be 'name' since that's what you use later - and would explain your
exception!
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 61:47:58 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,620 |