[Tutor] [Fwd: Please help, I'm a newbie]

Magnus Lycka magnus@thinkware.se
Fri, 27 Sep 2002 10:48:30 +0200


At 18:34 2002-09-27 +1200, Rob Brown-Bayliss wrote:
>On Tue, 2002-09-24 at 02:02, Dick Kniep wrote:
> >
> > Having searched a little further, it looks a little less weird, but I=20
> still
> > do not understand what is happening. It seems that the error occurs on=
=20
> the import
> > of the routine.

Yes. That is because of the indentation error. The "if..."
part is not inside the function, but in the scope of the
class. "column" doesn't exist there.

> > But I still don'y know what is happening here....
>
>It looks like columns isn't defiened becuase of the indentaion.

That's my impression too. Note that python assumes tabstop =3D 8.
Never ever ever mix spaces and tabs for indentation in a file.
This might not be the same as in your editor. Two tips:

  * Run python with the -t or -tt flag. This will give you warnings
    or errors due to inconsistent use of space/tab. (I think this
    should be default...)

  * Use an editor/IDE that can show whitespace, and use that. For
    instance in PythonWin "View->Whitespace"

>Also
>are you sure there is a 'columns' ?
>
>I know you define it in the init routine to be and empty [] but what
>happens if the calling routine passes a None to the columns variable?
>Then there is no columns variable (I think).

None and not existing is not the same thing. You remove
things with "del"

 >>> x =3D 5
 >>> print x
5
 >>> x =3D None
 >>> print x
None
 >>> del x
 >>> print x
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
NameError: name 'x' is not defined


--=20
Magnus Lyck=E5, Thinkware AB
=C4lvans v=E4g 99, SE-907 50 UME=C5
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se