[Tutor] Have a very simple question

Rob rob@uselesspython.com
Wed, 7 Aug 2002 17:10:26 -0500


That's right. And here are a few more things to ponder:

>>> print 'Is this a valid string, or isn't it?'
SyntaxError: invalid syntax
>>> print 'Quoth the raven, "I did not read poetry to that woman."'
Quoth the raven, "I did not read poetry to that woman."
>>> print 'Quoth the raven, "I didn't read poetry to that woman."'
SyntaxError: invalid syntax
>>> print """Quoth the raven, "I said I didn't do it.""""
SyntaxError: invalid token
>>> print '''Quoth the raven, "No, really... I didn't." '''
Quoth the raven, "No, really... I didn't."

When in doubt, trying out an idea in the Python shell is often the fastest
way to figure things out.

Rob

> -----Original Message-----
> From: Paul Harwood [mailto:harwood@nyclimits.org]
> Sent: Wednesday, August 07, 2002 4:56 PM
> To: Rob
> Subject: RE: [Tutor] Have a very simple question
>
>
> I think so. So I guess if you are using single quotes, it must follow
> that the string needs to be contained in double quotes?
>
> -Paul
>
>
> -----Original Message-----
> From: Rob [mailto:rob@uselesspython.com]
> Posted At: Wednesday, August 07, 2002 2:55 PM
> Posted To: Python
> Conversation: [Tutor] Have a very simple question
> Subject: RE: [Tutor] Have a very simple question
>
>
> The \ before the ' tells Python that you want the ' to be taken
> literally and not as the ' that would end the string.
>
> Does that help?
>
> Rob
>
> > -----Original Message-----
> > From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf
> > Of Paul Harwood
> > Sent: Tuesday, August 06, 2002 2:24 PM
> > To: tutor@python.org
> > Subject: [Tutor] Have a very simple question
> >
> >
> >
> >
> > Why does 'doesn\'t' translate to "doesn't" ? This is in the Python
> > tutorial but it doesn't say why this happens.
> >
> > -Paul
> >
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>