Goedemorgen!
Maak ik een stukje voorbeeldcode om te laten zien hoe je een static attribuut in een klasse benoemt, krijg ik onverwachte resultaten. Kan iemand mij uitleggen waarom 'tel1.aantal == 1' in onderstaande doctest? """ Static property test """ class Teller(object): """Tel hoeveel instanties er ooit zijn aangemaakt >>> Teller.aantal 0 >>> tel0 = Teller() >>> tel0.aantal 1 >>> tel1 = Teller() >>> tel1.aantal 2 """ aantal = 0 def __init__(self): """Constructor""" self.aantal += 1 def _test(): import doctest doctest.testmod() if __name__ == "__main__": _test() _______________________________________________ Python-nl mailing list Python-nl@python.org http://mail.python.org/mailman/listinfo/python-nl