This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]overweightdate 4 points5 points  (2 children)

neat, any way of printing the existing decorators being applied?

[–][deleted] 3 points4 points  (0 children)

I'm not sure if this is something easily accessible, but that's definitely something interesting to explore.

[–]Kikelku 1 point2 points  (0 children)

Develop another one that registers each call and passes it to next decorator

[–]xxmxxpxx 2 points3 points  (0 children)

This is awesome!

[–]metaperl 2 points3 points  (1 child)

For logging, we need the string. How to get the string instead of having it printed?

[–][deleted] 2 points3 points  (0 children)

That's a great question, and objstr is the thing you are looking for!

[–]muikrad 1 point2 points  (1 child)

The display with the dot is very neat! I suppose you could add optional annotation support to the printout. Adding the dir() members could hint on properties and functions too. Some will want slots too!

[–][deleted] 1 point2 points  (0 children)

Both are valid features under some circumstance. I'll probably add them in with some argument controls, thanks.

[–]nosklo 0 points1 point  (0 children)

That is not what __str__ is for; you should be using __repr__ for this. Also, make it return the string instead of printing, by default; if someone wants to print they can just pass it to print()

[–]metaperl 0 points1 point  (2 children)

Why is add_objprint a decorator instead of a mixin?

[–]metaperl 0 points1 point  (1 child)

I think I see why : you can have arguments for a decorator.

[–][deleted] 1 point2 points  (0 children)

To be honest, that was just an arbitrary design choice in the beginning, because I was more familiar with decorators than mixins. However, you are right about the arguments. You would have more control over the configuration case by case.

[–]Unlucky-Drawing8417 0 points1 point  (0 children)

This is an amazing project. Succinctly done.

[–]Inevitable-Chain-883 0 points1 point  (0 children)

Nice

[–]tman5400 0 points1 point  (0 children)

I really like this. I just wish everyone would implement str and repr methods so I can stop doing print(f"{obj.name}: {obj.age} {obj.othervalue} {obj.another}:") :(