[Tutor] Learning Regular Expressions

boB Stepp robertvstepp at gmail.com
Tue May 24 10:46:13 EDT 2016


On Mon, May 23, 2016 at 5:08 PM, Terry--gmail <terry.kemmerer at gmail.com> wrote:
> Running Linux Mint
> The YouTube Sentdex Video tutor I am following.
> He is working in Python3.4 and I am running Python3.4.3
>
> He's demonstrating some Regular Expressions which I wanted to test out. On
> these test scripts, for future referrence, I have been putting my notes in
> Tripple Quotes and naming the scripts descriptively to be able to find them
> again, when I need to review. However, this time, when  I copied in a simple
> script below my RE notes, and ran it from IDLE (and from Console) I got the
> following error:
>
> SyntaxError:  EOF while scanning triple-quoted string literal
>
> Now, there was also a tripple-quoted string I had set a variable to in my
> script...so I thought it was the active part of the script! But eventually,
> through the process of elimination, I discovered the scripted worked great
> without the notes!  I'd like to know what it is in the below Tripple-Quoted
> section that is causing me this problem...if anyone recognizes. In IDLE's
> script file..._it's all colored green_, which I thought meant Python was
> going to ignore everything between the tripple-quotes! But if I run just the
> below portion of the script in it's own file, I get the same While Scanning
> Tripple-Quotes error.

I do not know the exact point of error in your code, but even if you
use triple-quoted strings, escape sequences still work.  I do not have
a Python 3 installation handy, but in the Python 2.7.8 that I do have
handy:

Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print '''
\tTab character!!!
'''

        Tab character!!!

>>>

Note:  I had to simulate with spaces what I see in IDLE as my Gmail
refuses to accurately copy my IDLE result.

I suspect that your multiple backslash instances are generating what
you are observing.  Doesn't your full traceback target the exact line
of your code on which this occurs?

HTH,
boB


More information about the Tutor mailing list