-
-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
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".
Metadata
Metadata
Assignees
Labels
No labels