[Tutor] Non type object?

Kent Johnson kent37 at tds.net
Wed Mar 1 19:25:11 CET 2006

Max Russell wrote:
> None
> compStripToTxt is executed
> Traceback (most recent call last):
>   File "HeaderChecker.py", line 182, in ?
>     diff =checker.compStripToTxt(text, stripped)
>   File "HeaderChecker.py", line 114, in compStripToTxt
>     stripped = open(strippedfile, "r")
> TypeError: coercing to Unicode: need string or buffer, NoneType found
> Why is it returning the None type?
> How can I fix this?

It's because stripped is None in your main program, as the print 
statement shows. stripped is the value returned from stripFile(). Since 
stripFile() doesn't explicitly return anything, its return value is 
None. I think you want stripFile() to return the name of the stripped 
file, which is filetostrip.


More information about the Tutor mailing list