[Tutor] Stupid newbie question

Alan Gauld alan.gauld at btinternet.com
Wed Sep 28 09:58:08 CEST 2005

>>class startremail:
>>    def __init__(self):
>>     remailfile = open('U:\Bounce20.txt', 'r') 
>> #future
>>     def getday(self):
>>     def Read(self,line):

>>from startremail import *
>>x = startremail()
>>print x.getday()
>>I get the following return
>>NameError: name 'getday' is not defined
> It appears that you're being bitten by my least-favorite 
> ``feature''
> of python, indentation errors.  The getday routine appears to 
> be a
> subroutine of __init__, not a method of the class.

Actually he is being bitten by *lack* of indentation.
Indentation would help here not hinder! Unless you mean
that Python should insist on a dertain minimum amouint
of indentation..

If you use >=3 chars for indentation this kind of error
rarely happens, its only when using absurdly low indentation
spaces that this occurs. Indentation is intended to prevent
this but if you try to avoid using it then you get bitten...

Admittedly if Python used block markers to close a block
(ala Ruby) then the parser would identify a missing block
marker or if the markers matched parse correctly. So I
suspect Bill is actually objecting to the lack of block
markers not the use of indentation! ;-)

Alan G. 

More information about the Tutor mailing list