Skip to content

Conversation

@alexmojaki
Copy link
Collaborator

Closes #32

Example:

from icecream import ic

@ic
def foo(x, y):
    return x + y

a = 1
b = 2
foo(a, b)
ic| called foo(1, 2)
ic| foo returned 3

What should the output look like? ycecream does this on return:

y| returned 3 from foo(1, 2) in 0.000043 seconds

Do we want to show arguments again or timing? I'm hesitant, but it'd be easy to implement and we can change it later either way.

We still need an explicit API in case people want to decorate functions dynamically, e.g. foo = ic.decorate(foo) instead of @ic. Is ic.decorate() fine? My thinking is that it expresses "I am doing the equivalent of @ic", which is equally non-descriptive, so I don't know if it makes sense to have a descriptive name like ic.log_calls or a pun like ic.sandwich.

Still required after resolving questions:

  1. Allowing arguments, e.g. @ic().
  2. Tests.
  3. Releasing the required functionality in Decorators alexmojaki/executing#20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow ic to be used as a decorator

2 participants