Strings: double versus single quotes

Tim Chase python.list at tim.thechases.com
Sat May 23 12:03:09 EDT 2020


On 2020-05-24 01:40, Chris Angelico wrote:
> On Sat, May 23, 2020 at 10:52 PM Abdur-Rahmaan Janhangeer
> <arj.python at gmail.com> wrote:
> >
> > The interpreter prefers single-quotes
> >  
> > >>> "single or double"  
> > 'single or double'
> >  
> >>> 'not all that strongly, it doesn\'t'  
> "not all that strongly, it doesn't"

But when a string contains both, it biases towards single quotes:

   >>> "You said \"No it doesn't\""
   'You said "No it doesn\'t"'

;-)

-tkc





More information about the Python-list mailing list