Edge case though, as shown in title, when an attr name contains "\n", this attr won't be printed.
from objprint import op
op.config(arg_name=True)
class A:
def __init__(self):
self.x = 41
setattr(self, "\n", 42)
a = A()
for attr in dir(a):
if not attr.startswith("_"):
print(f"{attr}: {getattr(a, attr)}")
op(a)
Code above prints:
// a blank line here
: 42
x: 41
a:
<A 0x23202c55d30
.x = 41
>
a does have an attribute named "\n" whose value is 42, but op ignores it.
Actually regex made the mistake.
re.fullmatch(r"(?!_).*", '\n') # this returns None
Code in objprint.py wrote like above, mistakenly ignores those attr_names which contain "\n".
Edge case though, as shown in title, when an attr name contains "\n", this attr won't be printed.
Code above prints:
adoes have an attribute named "\n" whose value is 42, butopignores it.Actually regex made the mistake.
Code in
objprint.pywrote like above, mistakenly ignores those attr_names which contain "\n".