Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Why doesn't this method have access to its "self" argument? Date: Fri, 20 Nov 2015 04:34:29 +1100 Lines: 22 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de jD8X11ZOQROtgs//u5O8YwReUqUkNQI0nU2aFW9jU6Hw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'files:': 0.09; 'here?': 0.09; 'subject:Why': 0.09; 'subject:method': 0.09; 'python': 0.10; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'old-style': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:access': 0.16; 'test():': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'class,': 0.22; 'skip:= 20': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'minimal': 0.30; 'class': 0.33; 'add': 0.34; 'received:google.com': 0.35; 'so,': 0.35; 'nov': 0.35; 'robert': 0.35; 'received:209.85': 0.36; 'subject:" ': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'does': 0.39; 'latest': 0.64; 'between': 0.65; '20,': 0.66; 'python-list': 0.66; 'situation': 0.67; 'skip:= 30': 0.67; 'subject:have': 0.80; "'object'": 0.84; 'chrisa': 0.84; 'subject:its': 0.84; 'subject:self': 0.84; 'subject:this': 0.85; 'to:none': 0.91 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=SjV6tycUx4nwxTSaa70JnAVOjCWHZrsUc3juvNzGinM=; b=VBYZJZetBG/wa85s7s3I+5QrJZ/i5e6TiD8rKCAWuAQfPlkl7O5hEPEJs29NPHVsph jsD9QOVftqoEzEYJysqqLUN/yFw+BwwFig0AbsFcMOj9cMMOAxd8DWTdO844CBKwX7ET sC+3Ql7mfZNdBwgluYjoC4y2DD5FV6LUhU11zAEw6Lgpib2VapOgmFOGRqOkfDPsJyu9 ZmV5Twc+Cat+dv+uQrPZfH1hz7H/pXW9GizgVBHCx9naJbLOCj9XzMzzHrAMEPElSxJ5 833Y4hWHWpO+U3INWIosT0ovI3PjS20aAwJmvXE62oz9h0d4N4gCXd/bYdn8TCW9jqBL yelA== X-Received: by 10.50.183.11 with SMTP id ei11mr10490714igc.94.1447954470049; Thu, 19 Nov 2015 09:34:30 -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:99075 On Fri, Nov 20, 2015 at 3:13 AM, Robert Latest via Python-list wrote: > rl@dc:~/c/cwsf/python_module$ python test.py > > Minimal example files: > > ========================== test.py =================================== > > import cmethod > > class Test(): > > # add methods to the class "after the fact" > Test.py_method = py_method > Test.c_method = cmethod.c_method Are you using Python 2 here? If so, you're using an old-style class, which has specific consequences that I can never remember. Does the situation change if you slap 'object' between those parentheses? Or if you use Python 3? ChrisA