diff options
author | Malfurious <m@lfurio.us> | 2023-03-11 08:56:26 -0500 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2023-03-13 19:21:48 -0400 |
commit | a412a9a14a73f8041af34f0612c534c80bf9d13d (patch) | |
tree | 7e3f0939417b2511da7804274b1aee223d4c0f52 /hooks | |
parent | 1b4e81c5753bb551d9a81e174d851c98d63e0124 (diff) | |
download | sploit-a412a9a14a73f8041af34f0612c534c80bf9d13d.tar.gz sploit-a412a9a14a73f8041af34f0612c534c80bf9d13d.zip |
Prefer __repr__ for pretty-printing objects
Define human-readable string formatting for objects in repr, rather than
str, as this will enable an interactive interpreter to more conveniently
show this data to the user. I believe this especially makes sense in
cases where __str__ doesn't perform a semantic type conversion for its
class (currently, all affected cases).
Scripts can still easily yield this information by using
`print(object)`, as print will fallback to repr(object) when there is
not an explicitly defined __str__.
Furthermore, this patch still maintains backwards compatability (for the
time being) of using str(object) to retrieve the information. This is
because the default __str__ implementation will defer to __repr__ if
provided. This made the Symtbl case of providing both of them
especially redundant.
Signed-off-by: Malfurious <m@lfurio.us>
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to 'hooks')
0 files changed, 0 insertions, 0 deletions