[Tutor] dictionaries, objects and scoping...
John Morris
jrmorrisnc at gmail.com
Tue Jan 22 03:16:34 CET 2008
class Foo:
'''Represents a foo'''
def __init__(self, name):
'''Initializes the person's data'''
self.name = name
print '(Initializing %s)' % self.name
self.ot = Bar(self.name)
print '(After Other - %s)' % self.name
class Bar:
def __init__(self, name):
self.name = name
print 'Other', self.name
self.name.pop('srv')
print 'Other (Changed)', self.name
dict = { "srv" : "why", "goo" : "sticky" }
foo = Foo(dict)
print foo.name
Why does the pop in the Bar class nuke the srv k & v from Foo.name as well?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080121/b709b641/attachment.htm
More information about the Tutor
mailing list