mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
cast.from_str(): Add as alias to cast_str()
Using cast.from_str('blah') seems more logical than cast.cast_str(),
so add that alias and see how it fares.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
8f464fe278
commit
296dde387c
1 changed files with 4 additions and 1 deletions
|
|
@ -62,7 +62,7 @@ def guess_type(s: str, default=None, log_level=DEBUG, throw=False): # export
|
||||||
slog(log_level, msg)
|
slog(log_level, msg)
|
||||||
return default
|
return default
|
||||||
|
|
||||||
def cast_str(s: str, target_type=None, default_type=None, throw=True, log_level=WARNING, caller=None): # export
|
def from_str(s: str, target_type=None, default_type=None, throw=True, log_level=WARNING, caller=None): # export
|
||||||
if target_type is None:
|
if target_type is None:
|
||||||
target_type = guess_type(s, default_type)
|
target_type = guess_type(s, default_type)
|
||||||
if target_type is None:
|
if target_type is None:
|
||||||
|
|
@ -80,3 +80,6 @@ def cast_str(s: str, target_type=None, default_type=None, throw=True, log_level=
|
||||||
slog(log_level, msg)
|
slog(log_level, msg)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# deprecated name
|
||||||
|
def cast_str(s: str, target_type=None, default_type=None, throw=True, log_level=WARNING, caller=None):
|
||||||
|
return from_str(s, target_type=target_type, default_type=None, throw=True, log_level=WARNING, caller=None)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue