prompts.py
21 lines
| 607 B
| text/x-python
|
PythonLexer
fperez
|
r0 | # -*- coding: utf-8 -*- | ||
Thomas Kluyver
|
r22425 | """Being removed | ||
""" | ||||
Brian Granger
|
r2781 | |||
Thomas Kluyver
|
r5495 | class LazyEvaluate(object): | ||
"""This is used for formatting strings with values that need to be updated | ||||
Thomas Kluyver
|
r5496 | at that time, such as the current time or working directory.""" | ||
Thomas Kluyver
|
r5495 | def __init__(self, func, *args, **kwargs): | ||
self.func = func | ||||
self.args = args | ||||
self.kwargs = kwargs | ||||
Tayfun Sen
|
r21829 | |||
Thomas Kluyver
|
r5495 | def __call__(self, **kwargs): | ||
self.kwargs.update(kwargs) | ||||
return self.func(*self.args, **self.kwargs) | ||||
Tayfun Sen
|
r21829 | |||
Thomas Kluyver
|
r5495 | def __str__(self): | ||
MinRK
|
r7581 | return str(self()) | ||
Srinivas Reddy Thatiparthy
|
r23067 | |||
MinRK
|
r7571 | def __format__(self, format_spec): | ||
MinRK
|
r7578 | return format(self(), format_spec) | ||