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; 'cc:addr:python-list': 0.10; '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.22; 'defined': 0.22; 'cc:2**0': 0.23; 'example': 0.23; 'pass': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; '>>>>': 0.29; 'arguments.': 0.29; 'checking.': 0.29; 'implied': 0.29; 'class': 0.29; 'function': 0.30; 'file': 0.32; 'function.': 0.33; 'int': 0.33; 'traceback': 0.33; 'languages': 0.33; 'nov': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'method': 0.36; 'uses': 0.37; 'previous': 0.37; 'subject:: ': 0.38; 'perform': 0.38; 'received:192': 0.39; 'called': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'first': 0.61; '26,': 0.65; 'talking': 0.66; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply- to:no real name:2**0': 0.72; 'enforced': 0.84; 'received:74.208.4.194': 0.84; 'angel': 0.93 Date: Mon, 26 Nov 2012 21:50:00 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Ian Kelly Subject: Re: How to pass class instance to a method? References: <3193e3dd-0507-4ff7-9026-ee80e5d9c1dd@googlegroups.com> <50B3E617.3040302@davea.name> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:nBDwzgkaac0p4JLDBQoBt9pX87gHzF+r3OrBH/Cdj9M UyPCNwXU10Tjb2YtewdqSWXbdTXOh98W0qv30ubTRTpi/52Xp+ tnxVvg7xDrpIz3e70xklcexKemKrm5P2tocq4RS0daPXLHrPh5 2QZLcS7z2U0HdUjI9x3pXIeLGVyoNUJb6cj6h8Uzbb/cZISiKI +MMMYW93pOEMs7iB91pFStCdPxY0gZ4f5lmwRBJ3br8fWql5eD jRCn/xmfzbRY/Bw01715r171pF1n+wk8AmUlt5yvoBNlzZmdZ3 ERTk859j33EJAEvz8jXdMbgP5NeTZ2x3Xv8k5SHdtRHLWrcdg= = Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1353984622 news.xs4all.nl 6902 [2001:888:2000:d::a6]:54255 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.stben.net!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:33960 On 11/26/2012 06:07 PM, Ian Kelly wrote: > 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. We were talking about function arguments. I don't know of any place where they get their types declared. -- DaveA