On Tue, 11 Aug 2020, 02:20 Ganesh Pal, <ganesh1...@gmail.com> wrote:

> The possible value of stat['server2'] can be either (a)
> "'/fileno_100.txt'" or (b) '/fileno_100.txt' .
>
> How do I check if it the value was  (a) i.e string started and ended
> with a quote , so that I can use ast.literal_eval()
>

BAFP

>
def maybe_unquote(string):
    try:
        return ast.literal_eval(string)
    except ValueError:
        return string
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to