Dict in Class Problem

Sebastian Haas haas at ems-wuensche.com
Tue Oct 8 10:50:42 EDT 2002


Hello NG,

i have a little problem in Python.

code:

#! /usr/bin/python

class CTest:
	dicton = {}

first = CTest()
secon = CTest()

first.dicton['test'] = "RE"
secon.dicton['test'] = "BE"

print first.dicton['test']

Why is the output "BE", why not "RE".

With
	first = CTest()
	secon = CTest()
i get 2 new object, 2 objects that differs, or not??

The Keys are the same, okay, but i have 2 different objects (with 2 
different dictionarys).

I hope for help and thanks for help.

best regards,
Sebastian Haas




More information about the Python-list mailing list