Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'operator': 0.03; 'true,': 0.05; 'attribute': 0.07; 'referring': 0.07; 'string': 0.09; 'exception.': 0.09; 'literal': 0.09; 'method,': 0.09; 'namespace': 0.09; 'objects:': 0.09; 'referenced': 0.09; 'type,': 0.09; 'python': 0.11; 'def': 0.12; 'arg,': 0.16; 'brackets,': 0.16; 'callable': 0.16; 'dot,': 0.16; 'foo()': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'function?': 0.16; 'interesting:': 0.16; 'literal,': 0.16; 'magic': 0.16; 'methods;': 0.16; 'namespace,': 0.16; 'notation': 0.16; 'operator.': 0.16; 'operators.': 0.16; 'retrieving': 0.16; 'throw': 0.16; 'traverse': 0.16; 'world!': 0.16; 'world!")': 0.16; 'followed': 0.16; 'index': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'result.': 0.19; '>>>': 0.22; "aren't": 0.24; "i've": 0.25; 'equivalent': 0.26; 'somewhere': 0.26; 'skip:_ 20': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'operations,': 0.30; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'gives': 0.31; "d'aprano": 0.31; 'name;': 0.31; 'object.': 0.31; 'operators': 0.31; 'steven': 0.31; 'class': 0.32; 'another': 0.32; 'call.': 0.33; 'not.': 0.33; 'skip:_ 10': 0.34; 'maybe': 0.34; "can't": 0.35; 'something': 0.35; 'etc.)': 0.35; 'objects': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'object,': 0.36; 'sequence': 0.36; 'done': 0.36; 'two': 0.37; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'little': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'called': 0.40; 'according': 0.40; 'even': 0.60; 'no.': 0.61; 'back': 0.62; 'name': 0.63; 'refer': 0.63; 'fashion': 0.64; 'more': 0.64; 'different': 0.65; 'series': 0.66; 'anything.': 0.68; 'of:': 0.68; 'percent': 0.68; 'square': 0.74; 'kinda.': 0.84; 'subject:gets': 0.84; 'technically': 0.84; 'treating': 0.84; '2013': 0.98 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=UaQnwBpuZZTmTJTsKzZmZunD1PUYQrOmYCZAoL8psow=; b=ESuTbdHOpSo1aoeig6z0tZqs38k5mNO7E7/oVXobki3NHD1kittRmvVXZ2xSGSynck xfJPenJzEyBMZoYW7Ie3weScEu5qiQPa2/G4Xq8Y/xO7LC9lPyr80504XOjDk8PkJL4G k1MZxGbnPgUa76tBN56aPPVYWwhpbtcJoxq1hhdkbSsCZB7nruHuW4/lgWXnKhpRcXJR jQ8YoVx3Og3ihhTbKEiU/lpdNwlGU+XB76ZtyEETrpPdutwnRBMnRSLFXiV1LS3V1+1y WFgNzz2yP11T0BS1EGnDGFPVZRsoi3pYLyza520fhJlF/C8ZKMTkFZbr3DQ5qvuruGB/ eBMQ== MIME-Version: 1.0 X-Received: by 10.220.48.17 with SMTP id p17mr332296vcf.97.1371633252969; Wed, 19 Jun 2013 02:14:12 -0700 (PDT) In-Reply-To: <51c17208$0$29973$c3e8da3$5496439d@news.astraweb.com> References: <51ba6e92$0$29997$c3e8da3$5496439d@news.astraweb.com> <51C144AA.5060008@davea.name> <51C1666F.6050307@davea.name> <51c17208$0$29973$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 19 Jun 2013 19:14:12 +1000 Subject: Re: A certainl part of an if() structure never gets executed. 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.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: 80 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371633261 news.xs4all.nl 16003 [2001:888:2000:d::a6]:37128 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48702 On Wed, Jun 19, 2013 at 6:55 PM, Steven D'Aprano wrote: > On Wed, 19 Jun 2013 18:21:40 +1000, Chris Angelico wrote: > >> You can't reference an object without >> somewhere having either a name or a literal to start it off. > > True, but not necessarily a name bound to the object you are thinking of: > > some_function() > > gives you an object, but it's not a literal, and "some_function" is not > the name of the object you end up with. You start with the object identified by some_function, then you call it. Same thing. Okay, so according to the Python grammar some of these things I've been treating as operators aren't classified as them; but there are still operations done to existing objects to derive other objects: > The ways to refer to something are more > interesting: > > * you can refer to a thing directly by referring to it as a literal; > > * you can refer to a thing bound to a name by referring to the name; The two I started with > * you can refer to a thing in a namespace by referring to the namespace > in some fashion, followed by a dot, followed by the name in that > namespace, e.g. some_object.attribute, __import__('math').pi; Retrieving an attribute of an object, whether that object be referenced by name or by function call. > * you can refer to a thing in a sequence by referring to the sequence in > some fashion, followed by an index number in square brackets, e.g. seq[3]; Ditto. These can call magic methods; as far as I'm concerned, they're equivalent to operators. You can apply them to anything. > * you can refer to a thing that is returned by a callable (function, > method, type, etc.) by referring in some fashion to that callable object, > followed by calling it, e.g. functions[9](arg) gives you a reference to > some object which may not be any of `functions`, `9`, or `arg`. And same again. You start with functions, 9, and arg, look up two of them as names, traverse the series of operations, and get back a result. Or maybe you throw an exception. >>> class Foo: def __call__(self): print("Hello, world!") >>> foo=Foo() >>> foo() Hello, world! Is foo a function? Kinda. Sorta. We don't care. Is the function call notation () an operator? Ditto - we don't care. It works like one. There's little fundamental difference between: >>> "asdf %d qwer"%5 'asdf 5 qwer' and >>> "asdf %d qwer"[5] '%' but one of them is called an operator and one's not. Would you say that percent notation there is another way to reference an object? Is it a different type of string literal? No. It's a string literal and an operation done to it. Same with the subscripting, even though that's not technically an operator. It's not a different way to get an object. It's an operation on an object. ChrisA