Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Question about code writing '% i, callback' Date: Tue, 1 Dec 2015 09:53:40 -0600 Lines: 26 Message-ID: References: <25af8ac3-5fc7-44bd-a73f-7a870b69515a@googlegroups.com> <53ef7ef4-cfec-4c91-a45c-5b847dde8fad@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 8glkHV+vHxej5V+ZzIAXjAQhyS67kDzqxUrRYEn+yIfg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Question': 0.05; 'subject:code': 0.07; 'callback)': 0.16; 'ian.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:writing': 0.16; 'wrote:': 0.16; 'module,': 0.18; '2015': 0.20; '%s"': 0.22; 'fit': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'example': 0.26; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'equivalent.': 0.29; 'class.': 0.30; 'another': 0.32; 'class': 0.33; 'case,': 0.34; 'received:google.com': 0.35; 'instance': 0.35; 'nov': 0.35; 'item': 0.35; 'there': 0.36; 'created': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'method': 0.37; 'received:209.85.213': 0.37; 'itself': 0.38; 'received:209': 0.38; 'whatever': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'skip:u 10': 0.61; '30,': 0.63; 'to:name:python': 0.84; 'dennis': 0.91 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=nPCiOh4g7Eu+sgMQAHPthdqU+xwa12upXXBc1G3yXFE=; b=F8QFLer+04ySYA8LpayBBZuZAPlJiIprXjoX26UUfYKSp7IGozmebGXOJUC24Bpgbj dCwlPmLU16itq7n3wRqSGQewYzEgqQRXYPHfTZzmAHqUEixUxHS323MnEWa59Vqg1cM2 2YYU4IPnmVeNfwIsHIErXkw5CN5Dgv/+tnmKn8HSDtwQf9j8ISzg9K8XFYwuJYMMmzS6 6TEH/cuWCGh1WQqJ+JvVhJGcGXnlOvW2HnJ3Vnh6jW2ORNNjsW+dRPQE7ss0055yZ7UX UELbpvLbta1hIReFpEVchInnC8e0PYJ5ctpIkTVY94fV2niskbXDveMxroZSVW2VmXAI lGqw== X-Received: by 10.50.73.130 with SMTP id l2mr27495718igv.93.1448985259565; Tue, 01 Dec 2015 07:54:19 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99804 On Mon, Nov 30, 2015 at 7:44 PM, Dennis Lee Bieber wrote: > On Mon, 30 Nov 2015 10:55:23 -0800 (PST), fl declaimed > the following: > >>Thanks Ian. I created the class because I want to use the original example >>line >> >> UI.Button("button %s" % i, callback) >> >>Is there another way to use the above line without my class definition? >>I do feel that my created class does not match well with the above line >>because the first item "button %s" does not fit __self__ in the class. > > The first item passed to a method call is the instance object... In > this case, whatever "UI" is bound to. > > If it helps, think of > > UI.Button("string", callback) > as > Button(UI, "string", callback) This is only correct if "UI" is bound to an instance of a class and "Button" is a method of that class. If UI is a class itself or a module, then those are not equivalent.