Closed KOLANICH closed 4 years ago
I'm going to deny this pull request, the point of pout is to debug objects, which is why it is so verbose. If you only want the repr
of the objects, just call repr
, or you could set POUT_OBJECT_DEPTH=0
I guess if you still want to use pout.
I prefer the verbosity by default with configuration to make it less verbose.
@Jaymon, Are you going to merge 52edeba5315cd57b9353671e8f38c6647d35e762 ? I mean should I send a separate PR with it?
If you only want the repr of the objects, just call repr
In fact initially I wanted to write a lib just printing a repr and a variable name got via reflection and applying heuristics upon source code. But googled a bit and found this lib.
In order to merge https://github.com/Jaymon/pout/commit/52edeba5315cd57b9353671e8f38c6647d35e762 I'd love some more reasoning on why the changes were made. What problems did you find with extending pout that prompted the change?
I don't love the existing implementation, but the current approach of just extending pout.value.Inspect
to know about a new value or to change how a current value is interpreted and then setting the custom Inspect subclass into pout.value.Value.inspect_class
seems to be sufficient for anyone looking to customize the output for those that really need it
and then setting the custom Inspect subclass into pout.value.Value.inspect_class seems to be sufficient for anyone looking to customize the output for those that really need it
It is too much to redefine - everything was hardcoded, even if I replaced 1 class to make it work I had to replace all the classes. These means copypasting the sources. It is easier to rewrite the lib from scratch rather than to do copypastes and then maintain them. So now all the calls are routed through dicts.
The documentation on extending pout is not sufficient, you can actually completely replace the current Value system with your own by doing something like:
import pout
from pout.value import Inspect, Value
class MyInspect(Inspect):
@property
def classtype(self):
return MyValue
class MyValue(Value):
def string_value(self):
return repr(self.val)
pout.Value.inspect_class = MyInspect
class Foo(object):
bar = {"che": 1, "baz": 2}
f = Foo()
pout.v(f)
Would result in:
f = <__main__.Foo object at 0x10d025310>
(Untitled 2.py:42)
Likewise, you can selectively override just certain types if you want by doing something like:
# override just dictionary values
class MyInspect(Inspect):
@property
def classtype(self):
if self.is_dict():
return MyValue
else:
return super(MyInspect, self).classtype
It is in
contrib
dir. Usually into these dirs content made by third-party devs are placed that is not considered to be part of a main app, but enhance it and are shipped with it. So they are not necessarily must have the same dependencies, they can have own dependencies, but in order to use them the user should install these dependencies. This module is not imported by default, so if you don't use it, you don't have to installRichConsole
.It
repr
. I mean it is extremily inconvenient to see each object being expanded to >15 lines.tweak
is used), derives a background color as a complementary one (not the best solution:#7F7F7F
will give#808080
, which is nearly the same, but I have no idea what to do except just generating color in HSV model, using only hue and making other 2 values maximal, but this will greatly reduce the count of colors available and also human eye is more sensitive to brightness changes than to color ones) and applies them to the output. Currently it is done only for objects.