From 9689c204c8aac955a102a8c1a6cc613386606588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Al=C3=A1n=20Mu=C3=B1oz?= <alan.munoz@ed.ac.uk> Date: Wed, 15 Mar 2023 07:47:12 +0000 Subject: [PATCH] feat(cast): add module with casting operations --- src/agora/utils/cast.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/agora/utils/cast.py diff --git a/src/agora/utils/cast.py b/src/agora/utils/cast.py new file mode 100644 index 00000000..1a9fecd3 --- /dev/null +++ b/src/agora/utils/cast.py @@ -0,0 +1,16 @@ +#!/usr/bin/env jupyter + +""" +Convert some types to others +""" + + +def _str_to_int(x: str or None): + """ + Cast string as int if possible. If Nonetype return None. + """ + if x: + try: + return int(x) + except: + return x -- GitLab