osdir.com


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

Strings: double versus single quotes


On Wed, May 20, 2020 at 4:42 AM Joel Goldstick <joel.goldstick at gmail.com> wrote:
>
> On Tue, May 19, 2020 at 2:27 PM Chris Angelico <rosuav at gmail.com> wrote:
> >
> > On Wed, May 20, 2020 at 4:21 AM Manfred Lotz <ml_news at posteo.de> wrote:
> > >
> > > Hi there,
> > > I am asking myself if I should preferably use single or double quotes
> > > for strings?
> > >
> > > If I need a single quote in a string I would use double quotes for the
> > > whole string and vice versa. For f-strings I mostly see double
> > > quotes but single quotes would work as well I think.
> > >
> > > Is there a recommendation?
> > >
> >
> > Nothing strong. I tend to use double quotes because I have a
> > background in C (where double quotes are for strings, single quotes
> > for characters), and double quotes are the recommendation for
> > docstrings (see PEP 258). If you tend to work a lot with SQL, you
> > might prefer single quotes. Use whatever makes you happy.
> >
> I thought triple quotes are for docstrings?

Yes, but triple double quotes ==> """ <== not triple single quotes ==>
''' <== is what PEP 258 recommends. The description is awkward but
it's still a place where the double-quote character (U+0022 QUOTATION
MARK) is the recommendation.

On Wed, May 20, 2020 at 4:46 AM DL Neil via Python-list
<python-list at python.org> wrote:
> @Chris: are you on the night-shift?
Yes? :)

ChrisA