Closed lfashby closed 4 years ago
If you want to use segments
as library within a package, you may want to import it in function scope:
>>> import logging
>>> logging.basicConfig(level="INFO")
>>> def f():
... import segments
... logging.info('Logging to console')
...
>>> f()
INFO:root:Logging to console
Just wanted to put a +1 on @lfashby's issue---importing a third-party module inside of a function call to avoid an unnecessary side effect is very ugly!
I've created a PR that removes the basicConfig
call. As far as I can tell this has no negative consequences for the larger library. But perhaps there's some (untested) desirable side effect to calling basicConfig
at module scope in tokenizer.py. If so you can ignore the PR.
Importing the
segments
package leads to logging messages being absorbed by globallogging.basicConfig()
intokenizer.py
.For example:
While: