Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'arguments': 0.07; 'python': 0.09; 'parameter.': 0.09; 'tuple': 0.09; '(other': 0.16; 'backward': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hmm.': 0.16; 'new-style': 0.16; 'old-style': 0.16; 'subject:default': 0.16; 'threw': 0.16; 'tuple,': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'typing': 0.17; 'code,': 0.18; 'received:209.85.214.174': 0.21; 'lets': 0.22; 'class.': 0.23; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'am,': 0.27; 'object,': 0.27; 'then.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'all.': 0.28; 'fine': 0.28; "d'aprano": 0.29; 'shoot': 0.29; 'steven': 0.29; 'case,': 0.29; 'class': 0.29; 'classes': 0.30; 'code': 0.31; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; "wasn't": 0.36; 'method': 0.36; 'received:209': 0.37; 'well.': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'stand': 0.61; 'first': 0.61; 'limit': 0.65; 'jul': 0.65; 'yourself': 0.77; 'everything.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=1TeR3dsDI12hKr0vI08+ckIIAGIGY4NeZ7zypqhUlkA=; b=CiboWhG64UvYEjwmn1zt3xO94vHHTQAxmrtiOy5pmWSEh4y+W7IYfUXg6SuUzUIL/5 JuKnoj1pC8k65dWVYwX/ivTXfGGAzoTeZTjx3mJ0hFHHrio25fDNyWxeBOAZU1KBrPeY Pm7Tx5ZRbMyCxTSXGcRbfTjdcXhUibxrPAdDbCZ3xTfZg8qp2iqWmd4EfXWkKSJLghMr pYKn+gwh0gVP+gt28tzxvWV6vNfkTEf5wvUJK2nXT3FMfWHHcbrGtM6hztaUtZtM1o5Y gvHp4xXHd/UI7mLbPKQpi72CRaM+WNucafXjfpbDpCG71P3OBgQwbSD03snFZLGcZ7Zx MXXg== MIME-Version: 1.0 In-Reply-To: <500c99d5$0$29978$c3e8da3$5496439d@news.astraweb.com> References: <500c99d5$0$29978$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 23 Jul 2012 10:29:33 +1000 Subject: Re: default repr? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1343003376 news.xs4all.nl 6856 [2001:888:2000:d::a6]:59013 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25833 On Mon, Jul 23, 2012 at 10:24 AM, Steven D'Aprano wrote: >> Methods are just functions, and you can call any method of any class >> with any object as its first parameter. > > Not quite: they have to be an instance of that class. > >> Though this mightn't work with everything. I wasn't able to paint a list >> as a tuple - "tuple.__repr__([1,2,3])" threw a TypeError. Oh well. >> There's a limit to the ways Python lets you shoot yourself in the foot. > > Of course -- [1,2,3] is not a tuple, so how would tuple know what to do > with it? Hmm. I would have thought that methods were like all other functions: they take their arguments and do code with them. Duck typing and all. I stand corrected, then. In any case, it works fine for methods of object, at least with Python 3 and with new-style classes in Py2. (Other than backward compatibility with old code, is there any reason to use an old-style class?) ChrisA