Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'beginner': 0.05; '__init__': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'language.': 0.14; '__new__': 0.16; 'argument:': 0.16; 'ast': 0.16; 'constructs': 0.16; 'instances,': 0.16; 'positional': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:n 50': 0.16; 'subject:Classes': 0.16; 'typeerror:': 0.16; '\xe9crit': 0.16; 'language': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'trying': 0.19; 'header:User-Agent:1': 0.23; 'pass': 0.26; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'but': 0.35; 'instances': 0.36; 'doing': 0.36; 'method': 0.36; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'our': 0.64; 'charset:windows-1252': 0.65; 'age.': 0.84; 'received:btcentralplus.com': 0.84; 'received:86': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Classes Date: Fri, 31 Oct 2014 14:11:14 +0000 References: <51755at03r0bidjqh3qf0hhpvjr8756ill@4ax.com> <545350c3$0$23449$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host86-178-21-119.range86-178.btcentralplus.com User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <545350c3$0$23449$426a74cc@news.free.fr> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414764692 news.xs4all.nl 2909 [2001:888:2000:d::a6]:44074 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80017 On 31/10/2014 09:05, ast wrote: > > "Seymore4Head" a écrit dans le message de > news:51755at03r0bidjqh3qf0hhpvjr8756ill@4ax.com... >> class pet: >> def set_age(self,age): >> self.age=age >> def get_age(self): >> return self.age >> pax=pet >> pax.set_age(4) >> >> Traceback (most recent call last): >> File "C:\Functions\test.py", line 18, in >> pax.set_age(4) >> TypeError: set_age() missing 1 required positional argument: 'age' >> >> I am trying to pass 4 as the age. Obviously I am doing it wrong. >> > > Hi > > I am a beginner too, but I find it strange that your > pet class has no __init__ method to construct > instances __init__ initialises instances, __new__ constructs them -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence