I've stuck my neck out and am in the integration stage of a rather important project at my company, which wears dot net blinders. The program is not too big: I've cranked out 3K lines of code, quite a bit of which is unit tested, but my eyes are starting to glaze, and now I'm stuck (and not just my neck :-). If I can get the show back on the road and bring it to a conclusion, I'll be able to persuade a lot of people to look closely at Python (not to mention the job retention aspect :-).
The main jist of the problem is that I'm trying add data from one module to a list and a dictionary in another module, and it doesn't seem to stick over there. The programs below seem to illustrate the issue. (The results follow the programs). Why are the results different from runs of the two programs? The output of nameSpaceTestB.py makes sense to me, but I just don't get why nameSpaceTestA.py does what it does. I'm sure the reason is very simple, but I just don't see it. Please, can someone shed some light on the issue for me? Thanks! ~Peter --------------------------------- nameSpaceTestA.py: import nameSpaceTestB as NSB normalQ = [ 37] abc = 25 def indirect( ) : normalQ.append( 44) print "printing from NSA:" print normalQ NSB.updateNSA( ) print "printing from NSA:" print normalQ print "abc = %d" % abc if __name__ == '__main__' : indirect() --------------------------------- nameSpaceTestB.py: import nameSpaceTestA as NSA def updateNSA( ) : print "printing from NSB:" print NSA.normalQ NSA.normalQ.append( "gotcha") print NSA.normalQ print NSA.abc NSA.abc = 666 print NSA.abc if __name__ == '__main__' : NSA.indirect() --------------------------------- > py24 nameSpaceTestA.py printing from NSA: [37, 44] printing from NSB: [37] [37, 'gotcha'] 25 666 printing from NSA: [37, 44] abc = 25 > --------------------------------- > py24 nameSpaceTestB.py printing from NSA: [37, 44] printing from NSB: [37, 44] [37, 44, 'gotcha'] 25 666 printing from NSA: [37, 44, 'gotcha'] abc = 666 -- http://mail.python.org/mailman/listinfo/python-list