A scoping question

Gabriel Cosentino de Barros aut_gbarros at uolinc.com
Wed Dec 29 19:30:43 CET 2004

> myBaseClass.AddChild(file2.NextClass())
> [snip]
> class NextClass:
>     def __init__(self):
>         for eachChild in myBaseClass.MyChilds:  # <- ERROR
>             ...

I never assumes globals in my classes. always pass them as parameters. it's
safer and better to understand later. Also, makes it easier to reuse the
code later on.

myBaseClass.AddChild( file2.NextClass( myBaseClass ) )

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20041229/8046a9cd/attachment.html>

More information about the Python-list mailing list