Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.01; 'operator': 0.03; 'syntax': 0.04; 'interpreter': 0.05; 'subject:Python': 0.06; 'diff': 0.07; 'type,': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'repl': 0.16; 'appropriate': 0.16; 'student': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'asked': 0.31; 'didnt': 0.31; 'yourself.': 0.31; 'class': 0.32; 'subject: (': 0.35; "can't": 0.35; 'etc': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'mapping': 0.38; 'whatever': 0.38; 'pm,': 0.38; 'help,': 0.39; 'manually': 0.60; 'simple': 0.61; 'such': 0.63; 'taking': 0.65; 'situation': 0.65; 'between': 0.67; 'subject:! ': 0.74; 'day': 0.76; '2015': 0.84; 'answer:': 0.84; 'subject:!)': 0.84; 'surface': 0.84; 'discovering': 0.91; 'to:none': 0.92 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:cc :content-type:content-transfer-encoding; bh=LuInMXeHfQcGp+JK1xTLN59w9/Zxhb4Y4/00LaMm/UU=; b=JV95bEVMEBln3qMZf3vnebvWvIXNPJuKSalu/7vNtQJG8O6PKl3A9RS93/4/nMSo7G pDUMs8Ht5EQ7cTMYAUxTaPbiQECfg0dGUuhoCvb9CCKYa0MWmmAG9sVElVnv2wZ++n/E hRf+9fK4WWbajdFR9jGJGBvgu2+BoBPIBmn9odFYZllIEgb8YMh69ZSsfAwYy9e+h/Oa q9NcVqIF+9urdMCb/LYDwVT2dwaWJo99tCEaZJuvPNfJmWz9K+QYlA4JtTIibR7MBfUV YwpEETsolt62mL0RexxfzZ35NQLZjNZeoUIfHP++U3zxHe2U6GVe7CevjQw450cbV/fv GnGQ== MIME-Version: 1.0 X-Received: by 10.42.52.200 with SMTP id k8mr15957468icg.26.1422823555542; Sun, 01 Feb 2015 12:45:55 -0800 (PST) In-Reply-To: References: <54c07d04$0$13012$c3e8da3$5496439d@news.astraweb.com> <6eb91c4b-92ff-44a8-b5a9-6ef04c71f4cb@googlegroups.com> <35a40ec6-3763-448b-9ea4-4a233a04979b@googlegroups.com> <54c1ccc8$0$13005$c3e8da3$5496439d@news.astraweb.com> <54c6d7c2$0$12992$c3e8da3$5496439d@news.astraweb.com> <54c83ab4$0$12982$c3e8da3$5496439d@news.astraweb.com> <54ca583e$0$13005$c3e8da3$5496439d@news.astraweb.com> <54ccc2fc$0$13009$c3e8da3$5496439d@news.astraweb.com> <54cd9a7a$0$12984$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 2 Feb 2015 07:45:55 +1100 Subject: Re: dunder-docs (was Python is DOOMED! Again!) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422823564 news.xs4all.nl 2946 [2001:888:2000:d::a6]:54953 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85028 On Sun, Feb 1, 2015 at 4:36 PM, Rustom Mody wrote: > The other day I was taking a class in which I was showing > - introspection for discovering -- help, type, dir etc at the repl > - mapping of surface syntax to internals eg. a + b =E2=86=90=E2=86=92 a._= _add__(b) > > And a student asked me the diff between > dir([]) > and > [].__dir__() > > I didnt know what to say... Simple answer: You write dunder methods and the interpreter calls them. You don't call them yourself. I can't currently think of any situation where it's appropriate to call a dunder method manually (cue the swamping of such situations on the list); you just call dir() or the + operator or whatever it be. ChrisA