Definition problem

Andy Gimblett gimbo at ftech.net
Mon Mar 11 12:11:32 EST 2002


On Mon, Mar 11, 2002 at 10:02:46AM -0400, Ricks Palton wrote:

> What's the problem and what should I do?

The problem is that python uses indentation to denote program
structure.  As the traceback says, it expects an indented block.

What you should do is try to obtain a version in which this
indentation has been preserved properly.  Failing that, you'll have to
try to make the indentation right, which I've attempted to do in the
attached file.

Where did you get the code from?  Did you download it or
copy-and-paste?  Python is _very_ sensitive to whitespace in general
and so you need to be careful when, eg, downloading code from the net.
If you can save a .py to disk directly, that's usually best, as you'll
be more likely to be getting the code as its original programmer
intended.

mmtk_test.py, attached, contains the code as I speculate it should be
structured.  I might be slightly wrong, but as I don't have MMTK
installed I can't test it.  I'd hope that even if it's wrong, it'll
give you the gist of what's going on anyway.  Note that, of course, if
you don't have MMTK installed, you won't be able to run it either.
:-)

Finally, here's an FAQ entry explaining why python uses indentation
like this: http://www.python.org/doc/FAQ.html#6.2

Hope This Helps,

Andy

-- 
Andy Gimblett - Programmer - Frontier Internet Services Limited
Tel: 029 20 820 044 Fax: 029 20 820 035 http://www.frontier.net.uk/
Statements made are at all times subject to Frontier's Terms and
Conditions of Business, which are available upon request.




More information about the Python-list mailing list