Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12503
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ramit.prasad@jpmorgan.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'attributes': 0.05; 'completeness': 0.05; 'python': 0.08; 'decorator': 0.09; "object's": 0.09; 'wrong,': 0.09; 'def': 0.15; 'argument': 0.15; 'method.': 0.15; "subject:' ": 0.15; '(is': 0.16; '712': 0.16; 'above?': 0.16; 'currencies': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'privilege,': 0.16; 'received:155.180': 0.16; 'received:155.180.234': 0.16; 'received:159.53': 0.16; 'received:159.53.110': 0.16; 'received:169.70': 0.16; 'received:169.70.184': 0.16; 'received:169.70.184.72': 0.16; 'received:172.18.0': 0.16; 'received:172.18.0.232': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:hubcr105.exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'syntactic': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'val': 0.16; '>>>': 0.18; 'wrap': 0.18; 'seems': 0.20; 'header:In- Reply-To:1': 0.22; 'dictionary': 0.23; 'mask': 0.23; 'received:169.254.1': 0.23; 'to:name:python-list@python.org': 0.23; 'function': 0.27; 'somebody': 0.28; 'subject:need': 0.28; 'bit': 0.28; 'print': 0.29; 'example': 0.30; '(unless': 0.30; 'confused': 0.30; 'received:155': 0.30; 'received:159': 0.30; 'typeerror:': 0.30; 'class': 0.30; 'subject:?': 0.31; 'list': 0.32; 'does': 0.32; 'there': 0.33; 'to:addr:python-list': 0.33; 'received:169': 0.34; 'received:169.254': 0.34; 'received:172.18': 0.34; 'phone:': 0.35; 'object': 0.35; 'explain': 0.36; 'header:Received:8': 0.36; 'doing': 0.36; 'accuracy': 0.37; 'but': 0.37; 'some': 0.38; 'subject:: ': 0.39; 'i.e.': 0.39; 'to:addr:python.org': 0.39; 'hope': 0.61; 'double': 0.61; 'subject': 0.61; 'below': 0.62; 'information,': 0.65; 'legal': 0.70; 'why?': 0.73; 'url:email': 0.74; 'sale': 0.75; 'bank': 0.76; 'investment': 0.77; 'purchase': 0.84; 'self.value': 0.84; 'subject:always': 0.84; 'subject:class': 0.84; 'subject:self': 0.84; 'terminology': 0.84 |
| X-DKIM | Sendmail DKIM Filter v2.5.6 sj1.jpmchase.com p7VHCt9e014152 |
| DKIM-Signature | v=1; a=rsa-sha256; c=simple/simple; d=jpmorgan.com; s=smtpout; t=1314810776; bh=iQ2hGAlHnvD80Qh6tkgiUjPehlw/Alu88dZQ7vS vXJ0=; h=From:To:Date:Subject:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=aPlu3JXkHCy YmdtQ0z/XfXRtg2ovV7P+eKZZFm/sqKKAtzlWHUnbQXQhBEkMmoOPoHTSPozRmAXdVq kwiNiqCGdk8iPaSes1Gfm+FJgMz/S2yx263jxpuGVri6JPUahWT5TcBEOgeR4JS3U7w Q9yGRrwP/Or5MPUzRHjvidjyHg= |
| From | "Prasad, Ramit" <ramit.prasad@jpmorgan.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Date | Wed, 31 Aug 2011 13:12:48 -0400 |
| Subject | RE: Why do class methods always need 'self' as the first parameter? |
| Thread-Topic | Why do class methods always need 'self' as the first parameter? |
| Thread-Index | Acxn+4/84EaJSrW9RE2gvjj5DNPbfgAA0E3A |
| References | <0dc26f12-2541-4d41-8678-4fa53f347acf@g9g2000yqb.googlegroups.com> <j3lnlf$8eu$1@dough.gmane.org> |
| In-Reply-To | <j3lnlf$8eu$1@dough.gmane.org> |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| acceptlanguage | en-US |
| Content-Transfer-Encoding | base64 |
| MIME-Version | 1.0 |
| X-DLP-FWD | Yes |
| Content-Type | text/plain; charset="utf-8" |
| 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.619.1314810786.27778.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1314810786 news.xs4all.nl 2541 [2001:888:2000:d::a6]:59031 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12503 |
Show key headers only | View raw
>def double(obj): return 2*obj.value > >class C: > def __init__(self, val): > self.value = val > >c = C(3) >C.double = double >c.doub = double ># not c.double as that would mask access to C.double in c.double() below >print(double(c), C.double(c), c.double(), c.doub(c)) Sorry if I get some of the following terminology wrong, I get a bit confused on Python terms. I hope the following is still coherent. (Is there a dictionary of Python terminology?) Given the above example I get this >>> print c.double(c) TypeError: double() takes exactly 1 argument (2 given) >>> print c.doub(c) 6 It seems to me that if I add a function to the list of class attributes it will automatically wrap with "self" but adding it to the object directly will not wrap the function as a method. Can somebody explain why? I would have thought that any function added to an object would be a method (unless decorated as a class method). Hmm, or does the decoration just tell Python not to turn an object's function into a method? I.e. Is the decorator basically just the syntactic sugar for doing the above? Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why do class methods always need 'self' as the first parameter? "T. Goodchild" <tgoodchild@gmail.com> - 2011-08-31 07:35 -0700
Re: Why do class methods always need 'self' as the first parameter? John Gordon <gordon@panix.com> - 2011-08-31 14:54 +0000
Re: Why do class methods always need 'self' as the first parameter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-01 02:06 +1000
Re: Why do class methods always need 'self' as the first parameter? Grant Edwards <invalid@invalid.invalid> - 2011-08-31 16:20 +0000
Re: Why do class methods always need 'self' as the first parameter? Emile van Sebille <emile@fenx.com> - 2011-08-31 08:01 -0700
Re: Why do class methods always need 'self' as the first parameter? Neil Cerutti <neilc@norwich.edu> - 2011-08-31 15:05 +0000
Re: Why do class methods always need 'self' as the first parameter? Javier Collado <javier.collado@gmail.com> - 2011-08-31 17:10 +0200
Re: Why do class methods always need 'self' as the first parameter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-01 01:41 +1000
Re: Why do class methods always need 'self' as the first parameter? Chris Torek <nospam@torek.net> - 2011-08-31 20:15 +0000
Re: Why do class methods always need 'self' as the first parameter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-01 10:48 +1000
Re: Why do class methods always need 'self' as the first parameter? Chris Angelico <rosuav@gmail.com> - 2011-09-01 11:47 +1000
Re: Why do class methods always need 'self' as the first parameter? Eric Snow <ericsnowcurrently@gmail.com> - 2011-08-31 20:07 -0600
Re: Why do class methods always need 'self' as the first parameter? Chris Torek <nospam@torek.net> - 2011-09-01 02:20 +0000
Re: Why do class methods always need 'self' as the first parameter? Piet van Oostrum <piet@vanoostrum.org> - 2011-09-05 16:15 +0200
Re: Why do class methods always need 'self' as the first parameter? Chris Torek <nospam@torek.net> - 2011-09-06 01:10 +0000
Re: Why do class methods always need 'self' as the first parameter? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-09-06 14:31 +1000
Re: Why do class methods always need 'self' as the first parameter? Terry Reedy <tjreedy@udel.edu> - 2011-08-31 12:30 -0400
RE: Why do class methods always need 'self' as the first parameter? "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2011-08-31 13:12 -0400
Re: Why do class methods always need 'self' as the first parameter? Piet van Oostrum <piet@vanoostrum.org> - 2011-09-08 01:01 +0200
Re: Why do class methods always need 'self' as the first parameter? Chris Rebert <clp2@rebertia.com> - 2011-08-31 11:31 -0700
Re: Why do class methods always need 'self' as the first parameter? Ian Kelly <ian.g.kelly@gmail.com> - 2011-08-31 15:52 -0600
Re: Why do class methods always need 'self' as the first parameter? Terry Reedy <tjreedy@udel.edu> - 2011-08-31 18:40 -0400
Re: Why do class methods always need 'self' as the first parameter? UncleLaz <andrei.lisnic@gmail.com> - 2011-09-01 03:40 -0700
Re: Why do class methods always need 'self' as the first parameter? Michiel Overtoom <motoom@xs4all.nl> - 2011-09-01 13:23 +0200
Re: Why do class methods always need 'self' as the first parameter? John Roth <johnroth1@gmail.com> - 2011-09-01 05:45 -0700
Re: Why do class methods always need 'self' as the first parameter? Ian Kelly <ian.g.kelly@gmail.com> - 2011-09-01 08:26 -0600
Re: Why do class methods always need 'self' as the first parameter? John Roth <johnroth1@gmail.com> - 2011-09-02 10:51 -0700
Re: Why do class methods always need 'self' as the first parameter? Ian Kelly <ian.g.kelly@gmail.com> - 2011-09-02 14:30 -0600
Re: Why do class methods always need 'self' as the first parameter? John Roth <johnroth1@gmail.com> - 2011-09-02 15:30 -0700
Re: Why do class methods always need 'self' as the first parameter? rantingrick <rantingrick@gmail.com> - 2011-09-05 20:58 -0700
csiph-web