Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #55815

Re: Asterisk sign before the 'self' keyword

X-FeedAbuse http://nntpfeed.proxad.net/abuse.pl feeded by 88.191.16.109
Path csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!nospam.fr.eu.org!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python': 0.08; 'bind': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'tuple': 0.09; 'underlying': 0.09; 'syntax': 0.10; 'this:': 0.10; 'am,': 0.13; 'wrote:': 0.14; 'arguments': 0.15; 'class,': 0.15; 'brackets': 0.16; 'enigma': 0.16; 'hits.': 0.16; 'kern': 0.16; 'received:216.62': 0.16; 'received:216.62.213': 0.16; 'received:enthought.com': 0.16; 'subject:keyword': 0.16; 'interpret': 0.18; "subject:' ": 0.18; 'discussed': 0.21; 'somehow': 0.23; 'header:In-Reply-To:1': 0.23; "wasn't": 0.24; 'code': 0.25; 'function': 0.27; 'helpful': 0.27; 'third-party': 0.28; 'django': 0.29; 'class': 0.29; "subject: '": 0.30; 'to:addr :python-list': 0.31; 'header:X-Complaints-To:1': 0.32; 'name.': 0.33; 'enough': 0.33; 'does': 0.33; 'call,': 0.34; 'means,': 0.34; 'pass': 0.34; 'whether': 0.34; 'header:User-Agent:1': 0.34; 'received:org': 0.35; 'url:docs': 0.35; 'but': 0.36; 'anything': 0.36; 'though': 0.37; 'app': 0.37; 'forgive': 0.37; 'case,': 0.37; 'attempt': 0.38; 'url:org': 0.38; 'skip:f 20': 0.38; 'subject:: ': 0.39; 'refer': 0.39; 'some': 0.39; 'quickly': 0.39; 'url:python': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.40; 'could': 0.40; "it's": 0.40; 'world': 0.63; 'our': 0.64; 'believe': 0.65; 'show': 0.67; '__call__': 0.84; 'harmless': 0.84; 'refined': 0.84; 'to??': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Robert Kern <robert.kern@gmail.com>
Subject Re: Asterisk sign before the 'self' keyword
Date Fri, 11 Feb 2011 10:10:03 -0600
Organization The Church of Last Thursday
References <c2708e06-136b-43e3-94a9-91901fffeee8@s28g2000prb.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host outbound.enthought.com
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7
In-Reply-To <c2708e06-136b-43e3-94a9-91901fffeee8@s28g2000prb.googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.106.1297440619.1633.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 82.94.164.166
X-Trace 1297440619 news.xs4all.nl 81478 [::ffff:82.94.164.166]:59226
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:55815

Show key headers only | View raw


On 2/11/11 9:06 AM, christian.posta wrote:
> I searched quickly to see whether this may have been discussed before,
> but it's possible my search criteria was not refined enough to get any
> hits. Forgive me if this is a silly question..
>
> I was reading some Python code from a third-party app for the django
> project... i saw this in the code and I wasn't certain what it means,
> nor could I find anything helpful from google.
>
> Within the __call__ function for a class, I saw a method of that class
> referred to like this:
>
> *self.<method_name_here>()
>
> The brackets indicate the method name.
> What does the *self refer to??
> Does it somehow indicate the scope of the 'self' variable?

Can you show the whole statement? Most likely, this was embedded in some other 
call, e.g.:

   foo(*self.method())

If this is the case, the * does not bind to "self"; it binds to all of 
(self.method()), i.e.:

   foo(*(self.method()))

This is just the foo(*args) syntax that unpacks a tuple into individual 
arguments to pass to foo().

http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Asterisk sign before the 'self' keyword Robert Kern <robert.kern@gmail.com> - 2011-02-11 10:10 -0600
  Re: Asterisk sign before the 'self' keyword "christian.posta" <christian.posta@gmail.com> - 2011-02-11 08:57 -0800
    Re: Asterisk sign before the 'self' keyword "christian.posta" <christian.posta@gmail.com> - 2011-02-11 08:59 -0800
  Re: Asterisk sign before the 'self' keyword "christian.posta" <christian.posta@gmail.com> - 2011-02-11 08:59 -0800
  Re: Asterisk sign before the 'self' keyword "christian.posta" <christian.posta@gmail.com> - 2011-02-11 08:57 -0800

csiph-web