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


Groups > comp.lang.python > #76185

Re: odd difference calling function from class or instance variable

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'digest': 0.04; 'assign': 0.07; '(instead': 0.09; 'decorator': 0.09; 'explanation': 0.09; 'subject:instance': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'attributes,': 0.16; 'chris,': 0.16; 'descriptor': 0.16; 'doing,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:class': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'wed,': 0.18; 'bit': 0.19; 'basically': 0.19; 'normally': 0.19; "python's": 0.19; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'tonight': 0.24; 'decide': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; 'class': 0.32; 'stuff': 0.32; 'not.': 0.33; 'actual': 0.34; 'subject:from': 0.34; 'knowledge': 0.35; 'agree': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'thanks': 0.36; 'ahead': 0.38; 'pm,': 0.38; 'does': 0.39; 'how': 0.40; 'lower': 0.61; "you're": 0.61; "you'll": 0.62; 'prompt': 0.68; 'day': 0.76; 'homework': 0.84; 'peter,': 0.84; 'replies.': 0.84; 'treating': 0.84; 'to:none': 0.92; 'incredibly': 0.96
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; bh=ggsfj8wBXv8d5kO1HNlw9fQrxNltOKejrdttn8U8LBc=; b=Y16C/zgdazMgU4t9Bb1VHDT9I7psDB/rAAKPI13lChpYdTXXtPo35dejZb814zFl6i GeuIekaLyDcF/sH4pCMV/mHG40LfKWBJmKgyVVnK1zv3MwokkLva9DacyTz3LebuVbcs hfiSDQCZQB11dBAVSSbkfo0egAWiCh4+EHD+aTBhZwjtWobDKDuLRSp6L06Hv3tj7HS3 xTWENgRxQSY3R4ZtolvvevNiHuqbo6B1EaneYCnXmWYakrVZkijsWclu0+xAXAjm3Por szQSWWwWim0wB6ZDtIoD21osCMrXXHQTrfWM1ztOZeb1n6rT0FFtbLeB/UB2SofD5zPV aD7g==
MIME-Version 1.0
X-Received by 10.51.17.2 with SMTP id ga2mr6556563igd.2.1407925752461; Wed, 13 Aug 2014 03:29:12 -0700 (PDT)
In-Reply-To <2014081311203037705-not@myrealaddresscom>
References <201408131006549222-not@myrealaddresscom> <2014081311203037705-not@myrealaddresscom>
Date Wed, 13 Aug 2014 20:29:12 +1000
Subject Re: odd difference calling function from class or instance variable
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12919.1407925761.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407925761 news.xs4all.nl 2893 [2001:888:2000:d::a6]:47278
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76185

Show key headers only | View raw


On Wed, Aug 13, 2014 at 8:20 PM, GregS <not@my.real.address.com> wrote:
> Thanks to both of you for your incredibly prompt replies.  My homework for
> tonight is to digest the descriptor protocol...
>
> Peter, thanks for suggesting using staticmethod() to get the behaviour I was
> expecting.  I've only used staticmethod as a decorator before now.
>
> Chris, I agree that it's not every day you assign functions to class
> attributes, but it does have its uses (I won't bore you with mine).  Now
> that I know how it treads on the toes of Python's method magic, I can decide
> whether it's the best approach or not.

You seem to know what you're doing, which is a good start :) I aimed
my explanation a bit lower than your actual knowledge turns out to be,
so go ahead and do what you know you need to do. You're not treading
on Python's toes, here, but you're basically recreating some of what
Python normally does under the covers, so you'll need to actually
understand (instead of just treating as black-box magic) stuff like
the descriptor protocol.

ChrisA

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


Thread

odd difference calling function from class or instance variable GregS <not@my.real.address.com> - 2014-08-13 10:06 +0100
  Re: odd difference calling function from class or instance variable Peter Otten <__peter__@web.de> - 2014-08-13 11:40 +0200
  Re: odd difference calling function from class or instance variable Chris Angelico <rosuav@gmail.com> - 2014-08-13 19:45 +1000
  Re: odd difference calling function from class or instance variable GregS <not@my.real.address.com> - 2014-08-13 11:20 +0100
    Re: odd difference calling function from class or instance variable Chris Angelico <rosuav@gmail.com> - 2014-08-13 20:29 +1000

csiph-web