namespace question

xixiliguo wangbo.red at gmail.com
Fri Feb 24 06:55:02 CET 2012


c = [1, 2, 3, 4, 5]
class TEST():
    c = [5, 2, 3, 4, 5]
    def add( self ):
        c[0] = 15

a = TEST()


a.add()

print( c, a.c, TEST.c )

result :
[15, 2, 3, 4, 5] [5, 2, 3, 4, 5] [5, 2, 3, 4, 5]


why a.add() do not update c in Class TEST? but update c in main file



More information about the Python-list mailing list