Thanks Jerry and beiff , Jerry was right, it was an indent problem . Between using my text editor and running from commandline something went out of sync and I didnt catch it probably. I can now reproduce the error with a bad ident .
These are my first posts to comp.lang.python..and I am very grateful to everyone for their time . harijay On Oct 9, 12:07 pm, "Jerry Hill" <[EMAIL PROTECTED]> wrote: > On Thu, Oct 9, 2008 at 11:43 AM, harijay <[EMAIL PROTECTED]> wrote: > > Hi I am new to writing module and object oriented python code. I am > > trying to understand namespaces and classes in python. > > > I have the following test case given in three files runner , master > > and child. I am getting an error within child where in one line it > > understands variable master.name and in the next line it gives a > > NameError as given here > > <snip> > > > #File child.py > > class child(): > > def __init__(self,master): > > print "Master name is %s" % master.name > > print "Now seeting master name to setnameinchild in > > child.py " > > tmp = master.trash > > master.trash = master.name > > master.name = "setnameinchild" > > print "Reset name now from %s to %s , oldname %s is saved in > > mastertrash" % (master.trash, master.name , master.trash) > > The last line (starting with print), is not indented to the correct > level. Assuming it's supposed to be part of the child class's > __init__ method, it needs to line up with the rest of that method. > > -- > Jerry -- http://mail.python.org/mailman/listinfo/python-list