Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'attribute': 0.07; 'class,': 0.07; '__init__': 0.09; 'instance.': 0.09; 'works.': 0.09; 'def': 0.12; 'random': 0.14; 'called.': 0.16; 'class:': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'instance:': 0.16; 'kris': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'repetition': 0.16; 'wrote:': 0.18; 'working.': 0.19; 'seems': 0.21; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'point': 0.28; "doesn't": 0.30; 'sets': 0.30; 'statement': 0.30; 'prints': 0.31; 'class': 0.32; 'there.': 0.32; 'sense': 0.34; 'skip:_ 10': 0.34; 'subject:with': 0.35; "can't": 0.35; 'classes': 0.35; 'received:84': 0.35; 'but': 0.35; 'there': 0.35; 'crazy': 0.36; 'method': 0.36; 'should': 0.36; 'to:addr :python-list': 0.38; 'anything': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'subject:back': 0.60; 'numbers': 0.61; 'subject:more': 0.64; 'between': 0.67; 'header:Reply-To:1': 0.67; 'atm': 0.68; 'reply-to:no real name:2**0': 0.71; '10:': 0.84; 'frustrating': 0.84; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=ZMDuxxLb c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=0kkAYlmtguIA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=NnfSt9Y7ZA4A:10 a=Uzh8gwdv3Pazvh1Pq5EA:9 a=wPNLvfGTeEIA:10 X-AUTH: mrabarnett:2500 Date: Tue, 13 Aug 2013 04:31:15 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: back with more issues References: <88f95aab-0274-48ee-a68a-14a8c3b36e9c@googlegroups.com> In-Reply-To: <88f95aab-0274-48ee-a68a-14a8c3b36e9c@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376364680 news.xs4all.nl 15871 [2001:888:2000:d::a6]:39342 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52436 On 13/08/2013 04:13, Kris Mesenbrink wrote: > the Classes and __init__ still don't make much sense actually. i have tried and tried again to make it generate numbers between 0 and 5 in a while statement but it just doesn't seem to be working. > > import random > > > class Player(): This sets an attribute of the class: > hp = 10 This method will be called to initialise an instance of the class when one is created: > def __init__(self, patt): This sets an attribute of the instance: > self.att = random.randint(0,5) > > > > while Player.hp == 10: This prints the __init__ method of the class: > print (Player.__init__) > > atm it seems to be printing "" over and over again, i don't mind the repetition but from my understanding there should be numbers there. numbers that change. crazy frustrating that i just don't understand how this works. > At no point does it create an instance of the class, so the __init__ method is never called. You can't return anything from the __init__ method because it's called just to initialise the instance.