12.08.20 18:53, MRAB пише:
> I would suggest:
>
while s[ : 1] in {'"', "'"} and s[ : 1] == s[-1 : ]:
> ... s = s[1 : -1]
And the condition can be written as
s[ : 1] == s[-1 : ] in {'"', "'"}
or more efficiently as
s and s[0] == s[-1] in '\'"'
--
https://mail.python.org/mailm
On Tue, 11 Aug 2020, 02:20 Ganesh Pal, 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 ma
On 2020-08-11 20:43, Dennis Lee Bieber wrote:
On Tue, 11 Aug 2020 14:17:39 -0400, Joel Goldstick
declaimed the following:
[snip]
Warning -- it will fail if the input is just a pair of quotes or pair of
apostrophes -- improvement is
while s and s[0] in ['"', "'"]:
... if s[0] == s[-1]: