Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to disable showing the name of the variable? #171

Open
kacperpaczos opened this issue Dec 24, 2023 · 1 comment
Open

How to disable showing the name of the variable? #171

kacperpaczos opened this issue Dec 24, 2023 · 1 comment

Comments

@kacperpaczos
Copy link

In this code:

from icecream import ic as original_ic
import datetime

def ic(*args, **kwargs):
    current_time = datetime.datetime.now().strftime("%H:%M:%S")
    log_message = f"<<{current_time}>> " + " ".join(map(str, args))
    try:
        original_ic(log_message, **kwargs)
    except Exception as e:
        original_ic(f"An error occurred: {e}")

I have output:

log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '
log_message: '<<22:49:48>> '

In this case, log_message is not necessary. How to disable showing the name of the variable?

@gruns
Copy link
Owner

gruns commented Jan 9, 2025

@kacperpaczos likely best just to use print() here instead of ic(). unless you have a lot of other ic configuration you want to use, too. like ic.configureOutput(includeContext=true)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants