Someone enlightened me

M

Marcus Low

Opps here is the mail again, incase my formatting is lost, can someone
explain to me why this code behaves differently when "lister" and
"self.lister" is swap remarked.


class abc :
# remark this later and unremark "self.lister"
lister = []
def __init__ (self, val):
#self.lister = []
self.lister.append(val)

globallist = []


def test () :

global l
for x in range(10) :
o = abc(x)
globallist.append(o)
o = ""

for i in globallist :
print i.lister

test()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top