"End Of Line" Confusion

N

ncf

I'm having an odd problem. I'm getting an error from IDLE saying "End
Of Line detected while scanning single-quoted string." Odd thing is,
it's not single-quoted, it's one of the doc-strings (if that's what you
call them).

In the following code (class name replaced with <<<NAME>>>), the error
is being highlighted as the hyphen joining "non" and "ASCII".

class <<<NAME>>>:
<<<CUT>>>
def digest():
''' char[28] digest ( )

Return the digest of the strings passed to the update() method
so far.
This is a 28-byte string which may contain non-ASCII
characters,
including null bytes.
'''
raise NotImplementedError, 'digest() is not yet implemented.'


Thanks in advance. -Wes
 
J

Jordan Rastrick

Well, copying and pasting this text, and changing <<<NAME>>> to Foo so
that its a legal Python identifier (why did you not want to name your
class, out of curiosity), I get no problems with this.

class Foo:
def digest():
''' char[28] digest ( )

Return the digest of the strings passed to the update() method
so far.
This is a 28-byte string which may contain non-ASCII
characters,
including null bytes.
'''
raise NotImplementedError, 'digest() is not yet implemented.'
<__main__.Foo instance at 0x00B30C38>

So all I can suggest is that you have accidentally mixed double and
single quotes, or there is a quote mark somewhere in the docstring in
your copy of the code, or some strange, platform/system/text editor/etc
specific bug is causing this, or i don't know what else.

Oh and btw, I suspect, form the lack of @staticmethod on the line above
def digest():, that you perhaps meant def digest(self): ?
 
N

ncf

First off, my apologies...Google Groups doesn't seem to want to let me
reply inline.

I refrained from putting the name in there as it's potentially
offensive (gotta love America). If you would aid you, I can send you
the entire Python script via. email. Editor was IDLE on Slackware Linux
using the ReiserFS Filesystem (not like the FS matters :p).

There is not a quote mark in the docstring. What I posted for the
function def is a straight-forward copy and paste.

I'll try doing a hex-dump on the file and see if there's any odd bytes
in there that shouldn't be. Yea, I think I did mean that. :p I hadn't
yet even *begun* to work on the other areas...just working on the
bit-wise math and what-not.

-Wes
 
J

Jordan Rastrick

If you email the script to me, I'd be happy to take a look at it and
see if I come up with the same error (I'm running IDLE on a Windows XP
box here, cant remember if the filesystem is FAT or NTFS ;-))

Although as a relative newbie I've never come across it myself, one
possible source of such mysterious errors in Python, apparently, is
mixing tabs and spaces in your indentation. Its also one of the few
factors I can think of that would have been lost in the
email-copy-paste process, which could explain why the code snippet
works on my machine and not yours.

My only other suggestion is to try my personal first rule for fixing
mysterious, unusual bugs in small, trivial pieces of code - which is to
delete the whole thing and type it out again from scratch. It works
surprisingly often.

Good luck
- Jordan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,239
Messages
2,571,200
Members
47,840
Latest member
Tiffany471

Latest Threads

Top