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


Groups > comp.lang.python > #20387

Re: how to tell a method is classmethod or static method or instance method

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <dllizheng@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.052
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'subject:method': 0.09; '"test"': 0.16; 'a()': 0.16; 'btw:': 0.16; 'out?': 0.16; 'subject:instance': 0.16; 'cc:addr:python-list': 0.16; 'question.': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'cheers,': 0.20; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'static': 0.24; 'cc:2**0': 0.26; 'figure': 0.26; "i'm": 0.28; 'class': 0.29; 'problem': 0.29; 'cc:addr:python.org': 0.29; 'invoke': 0.30; 'message-id:@gmail.com': 0.31; 'quite': 0.31; 'actually': 0.31; 'does': 0.32; 'it.': 0.33; 'curious': 0.34; 'received:209.85.160': 0.36; 'question': 0.36; 'charset:us-ascii': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'received:192': 0.38; 'received:209.85.160.46': 0.39; 'received :mail-pw0-f46.google.com': 0.39; 'subject:how': 0.39; 'received:209': 0.39; 'header:Message-Id:1': 0.62; 'here.': 0.64; 'cause': 0.67; 'cameron': 0.77; 'serious': 0.78; 'mr.': 0.85; 'subject:tell': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=AWPqJoqvfTdyWqBLaxy7gOBb7j9H8ffrtA3s+LWtZhE=; b=hpHvLLsbi1DoS8jzLN8FT71Y9OFmsR2GIck+TkqZbNsyhxv11PnAdgKWxFmgckQ2SN TZa5nPlTBsf8NT+nDw/n6SGEINfQwGNfWztzQe3hukHKHZE1UYsir4UyogdAC8PpmmwQ 91iBfDg3c2V4KDtwiihA1C6F5gRz0wIPFeP2k=
Subject Re: how to tell a method is classmethod or static method or instance method
Mime-Version 1.0 (Apple Message framework v1257)
Content-Type text/plain; charset=us-ascii
From Zheng Li <dllizheng@gmail.com>
In-Reply-To <20120213072339.GA9132@cskk.homeip.net>
Date Tue, 14 Feb 2012 13:13:59 +0900
Content-Transfer-Encoding quoted-printable
References <E064CE77-0EB1-4D0B-9A47-E515EA621248@gmail.com> <20120213072339.GA9132@cskk.homeip.net>
To Cameron Simpson <cs@zip.com.au>
X-Mailer Apple Mail (2.1257)
Cc python-list <python-list@python.org>
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.5791.1329192844.27778.python-list@python.org> (permalink)
Lines 44
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1329192844 news.xs4all.nl 6851 [2001:888:2000:d::a6]:52590
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20387

Show key headers only | View raw


I can get "method1" of class "Test" by
a = getattr(Test, "method1")

and I also want know how to invoke it
a()	or	a(Test())



BTW:
I don't see what the problem is if I ask a question just because I am curious about it.


On 2012/02/13, at 16:23, Cameron Simpson wrote:

> On 13Feb2012 15:59, Zheng Li <dllizheng@gmail.com> wrote:
> | how to tell a method is class method or static method or instance method?
> 
> Maybe a better question is:
>  under what circumstances do you need to figure this out? 
> 
> I'm actually quite serious here. Please outline what circumstances cause
> you to want to ask and answer this question.
> 
> Cheers,
> -- 
> Cameron Simpson <cs@zip.com.au> DoD#743
> http://www.cskk.ezoshosting.com/cs/
> 
> Reason #173 to fear technology:
> 
>    o       o       o       o       o       o      <o      <o>
>   ^|\     ^|^     v|^     v|v     |/v     |X|      \|      |
>    /\      >\     /<       >\     /<       >\     /<       >\
> 
>    o>      o       o       o       o       o       o       o
>    \       x      </      <|>     </>     <\>     <)>      |\
>   /<       >\     /<       >\     /<       >\      >>      L
> 
>             Mr. email does the Macarena.

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


Thread

Re: how to tell a method is classmethod or static method or instance method Zheng Li <dllizheng@gmail.com> - 2012-02-14 13:13 +0900

csiph-web