Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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; 'python.': 0.02; 'argument': 0.04; 'run-time': 0.05; 'parameter': 0.07; 'statically': 0.07; 'subject:How': 0.09; 'python': 0.09; 'declarations': 0.09; 'subject:method': 0.09; 'typed': 0.09; 'typeerror:': 0.09; 'def': 0.10; 'language,': 0.11; 'static': 0.13; 'foo(object):': 0.16; 'subject:class': 0.16; 'subject:instance': 0.16; 'subject:pass': 0.16; 'unbound': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'instance': 0.17; '>>>': 0.18; '"",': 0.22; 'defined': 0.22; 'example': 0.23; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'message- id:@mail.gmail.com': 0.27; 'checking.': 0.29; 'implied': 0.29; 'class': 0.29; 'received:209.85.215.46': 0.30; 'function': 0.30; 'file': 0.32; 'function.': 0.33; 'int': 0.33; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'languages': 0.33; 'received:google.com': 0.34; 'nov': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'method': 0.36; 'uses': 0.37; 'previous': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'perform': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'first': 0.61; '26,': 0.65; 'enforced': 0.84; 'to:name:python': 0.84; 'angel': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=DgFtFnai8DH1HIuOOF2fcmpJSHZ/1XxxY/8u3mDyhK8=; b=hQcj8X5VIEcobDeQdVeDNobKFKLkNw63D0kZTe6IHEL9OcGEfVcojXN4WyuRxRowHX 9YcG+xiGyDwJjsWKf1UVGozMVphUfs8ihZrDN5s16KEVaqgoYTXP5cpZtYvts8mit3et Yfyr+f3p24u91dTd15jDkpRgXhMxBdLW6a0bZL3BGHoiVQAo+RymH1zzLW9C0d84Fetb 7JBmVeS9B1PB9Fk6FTSkeTNoEwJ6Yfsgr7Hm/SlenCQ/kjyySPZnGWafHnpeWnfigzpF NquOQEvHsV4SoHZlciXSbUVaJxz+8AYWl4O3HW1hRM93V3ehlOJ3+DfRHCLaqQPoqBNk P1+Q== MIME-Version: 1.0 In-Reply-To: <50B3E617.3040302@davea.name> References: <3193e3dd-0507-4ff7-9026-ee80e5d9c1dd@googlegroups.com> <50B3E617.3040302@davea.name> From: Ian Kelly Date: Mon, 26 Nov 2012 16:07:10 -0700 Subject: Re: How to pass class instance to a method? To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353971263 news.xs4all.nl 6879 [2001:888:2000:d::a6]:33568 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33954 On Mon, Nov 26, 2012 at 2:58 PM, Dave Angel wrote: > Not how I would put it. In a statically typed language, the valid types > are directly implied by the function parameter declarations, As alluded to in my previous post, not all statically typed languages require parameter type declarations to perform static checking. > while in a > dynamic language, they're defined in the documentation, and only > enforced (if at all) by the body of the function. That's not even true for Python. The following example uses Python 2.x: >>> class Foo(object): ... def method(self): ... pass ... >>> Foo.method(4) Traceback (most recent call last): File "", line 1, in TypeError: unbound method method() must be called with Foo instance as first argument (got int instance instead) That's a run-time check, and it's not enforced by the body of the function.