Open trim21 opened 1 month ago
Nice! Wouldn't it be easier to just accept a supplier function (i.e. lambda: "Hello"
or an object method None.__str__
) to be evaluated instead of a custom class?
Nice! Wouldn't it be easier to just accept a supplier function (i.e.
lambda: "Hello"
or an object methodNone.__str__
) to be evaluated instead of a custom class?
I think that's very strange behavior for "formatting"
If anything, it already exists as an external library like lazy-string
for example.
I agree it's more powerful than the current opt(lazy=True)
design.
If anything, it already exists as an external library like
lazy-string
for example.I agree it's more powerful than the current
opt(lazy=True)
design.
it only support old style percent formatting, not new style {}
formatting
from lazy_string import LazyString
from loguru import logger
def make_foo() -> int:
return 1
logger.info("nice, {:05d}".format(LazyString(make_foo)))
Traceback (most recent call last):
File "C:\Users\Trim21\proj\test\f.py", line 9, in <module>
logger.info("nice, {:05d}".format(LazyString(make_foo)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to LazyString.__format__
since we are using new style format, it's possible to control how value are formatted with
__format__
current
lazy
option is not necessary, we can add aLazyValue
type, this make is possible to mix lazy and un-lazy arguments