[python-nl] static attribuut in klasse definitie

Wichert Akkerman wichert at wiggy.net
Wed Dec 20 10:12:25 CET 2006


Previously Robert-Reinder Nederhoed wrote:
> 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?

omdat je self.aantal een instance variable maakt. als je Teller.aantal
in je __init__ had gebruikt was het wel goed gegaan.

Wichert.

-- 
Wichert Akkerman <wichert at wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.


More information about the Python-nl mailing list