sloria / konch

Configures your Python shell.
https://konch.readthedocs.io/
MIT License
406 stars 18 forks source link

Prevent error when objects have no __name__. #101

Closed brl0 closed 5 years ago

brl0 commented 5 years ago

Created function get_obj_name to try to get the name attribute, otherwise return empty string.

sloria commented 5 years ago

How did you produce this error? Would be great to have a test for this.

Also, what happens if there are multiple objects with no __name__? Won't they clash in the context dictionary?

brl0 commented 5 years ago

Great point about multiple modules with blank names, haven't tested that yet but you are right about the blank name collision issue. I'll see if I can get the object hash id to use instead, or any other method you prefer to resolve collisions.

The error occurred when trying to add a third-party logging module, loguru, to the .konchrc file. To install loguru: pip install loguru Import statement added to .konchrc file: from loguru import logger

sloria commented 5 years ago

This appears to now have two unrelated changes: the __name__ fix and the get_config change (which I'm not sure is necessary). Can you split these out into separate PRs please?