bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Python 'strings'


From: Bruno Haible
Subject: Re: Python 'strings'
Date: Sun, 25 Feb 2024 13:02:08 +0100

Summarizing the rationale to use 'abc' as string syntax:

* PEP 8 https://peps.python.org/pep-0008/#string-quotes
  says "In Python, single-quoted strings and double-quoted strings are
  the same. This PEP does not make a recommendation for this. Pick a rule
  and stick to it."

* When I search where the literal string 'foo' occurs, I don't want to make 2
  searches (for 'foo' and for "foo"), nor a regex search (for ['"]foo['"]).
  Simple things should remain simple. A certain canonical way to denote
  literal strings is necessary for this. (Btw, JavaScript has the same
  problem.)

* The Python interpreter prints strings with single-quotes:

  >>> "abc"
  'abc'

So, that makes the single-quotes the natural choice.

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]