-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
singledispatch argumentToString #115
Conversation
Cool idea! However this doesn't work in Python 2. That doesn't mean you have to drop this PR or implement singledispatch for the sake of Python 2, this could be a Python-3-only feature, just make sure that not everything breaks when |
@alexmojaki |
neat idea! one important item: every action needs to have a reciprocal undo action. insofar, there should be a way to i leave it up to you two to figure out the best API, but at minimum |
@gruns I overrided singledispatch to add unregister and avoid ImportError Python2.
This is already possible argumentToString.registry
# mappingproxy({object: <function icecream.icecream.argumentToString(obj)>,
# numpy.ndarray: <function __main__.argumentToString_ndarray(obj)>}) I will also add tests. |
done with adding test |
👌
👌 |
Looks good overall, it just also needs some docs next to the existing ones for argToStringFunction. |
Co-authored-by: Alex Hall <[email protected]>
Definitely! I will update README.md tomorrow! Just for sure, is this the doc you mean? Lines 276 to 293 in 7bf20d4
|
Yes |
@alexmojaki Thanks. I added documentation. |
Co-authored-by: Alex Hall <[email protected]>
no more comments from me. docs look pretty good. thank you for your wonderful work, @atusy! ill rerun tests and release to pypi this weekend. thx for the reminder, @alexmojaki 🙏 |
Thank you @gruns and @alexmojaki |
all tests pass 🙌 icecream v2.1.2 now out: https://pypi.org/project/icecream/ @atusy: huge thank you for your PR! i added a sincere shoutout to your work in the changelog https://github.com/gruns/icecream/blob/master/changelog.txt#L4 |
@gruns Thank you, too!!! |
Current implementation requires users to rewrite
argToStringFunction
totally.I would suggest singledispatch
argumentToString
, which allows sort of ad-hoc way to stringify the argument.This makes codes shorter.
Also, This is very handy especially on Jupyter Notebook because users may add customizations in working cells, instead of going back to the cell which defines custom
argToStringFunction
in a current manner.