From: D-Man <ds...@ri...> - 2001-06-13 20:23:33
|
On Wed, Jun 13, 2001 at 11:50:07AM -0600, Benjamin Collar wrote: | Hi there, | | I'm getting a warning I haven't seen before. Can someone tell me exactly | what it means? | | /home/bcollar/work/ecommerce/AppTester.py:4: SyntaxWarning: local name | 'self' in '__init__' shadows use as global in nested scopes | def __init__(self, *TestClasses): You have something like : ######## a module self = "some value" print id( self ) class Foo : def __init__( self , *TestClasses ) : print id( self ) The 2 'print' lines will print different things -- the 'self' inside the __init__ function is a different 'self' than outside the function. The solution is to change the name of one or more of them. It is also conceivable that you have class Foo : def func( self ) : class Bar : def __init__( self ) : pass which would cause the same problem, when nested_scopes are used. If you show the rest of the code, then it will be more obvious what is really causing the warning message, and it will be easier to suggest alternative coding/naming styles. -D |