Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90560
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.mixmin.net!feeder1.xsusenet.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| 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; '(at': 0.04; 'parameters': 0.04; 'wednesday,': 0.07; '*args,': 0.09; '__init__': 0.09; 'def': 0.12; '15:25': 0.16; '__new__': 0.16; 'args,': 0.16; 'arguments:': 0.16; 'called,': 0.16; "object's": 0.16; 'object()': 0.16; 'subject:object': 0.16; 'subject:skip:m 10': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'result.': 0.19; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'andrew': 0.30; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; '13,': 0.31; '>>>>': 0.31; 'object.': 0.31; 'parameters.': 0.31; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'new': 0.61; 'thomas': 0.65; '2015': 0.84; 'rachel': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=5nLIy+neW0dPqQc5ZCXBVzVGutXBdx/9mhUDfjKJWJM=; b=nflCuxAcFhAkg7oy7URinO5y232E4iJkVDbk5lwSL8BSurimhxyj94/dBHjr5WrAqE yxEljF16MCe0NK3ffAWjuAea9GVJ4uB0s7u5TCYHU+JsPOw5Me2hG3m7LIplAtnBrL5b zw6i2WhLtA4fLrlxvcHOewPlvNjjrR0GER/RgEVlFJSUAUkhVGJ8x5BIlsVM3O1hYBqN zMKCeDezCNsmEq9nwoCosdDKusqOrKz1YJyrv2nxRJQSCRtinS6Q5TLcbV0IpKQuOhC2 zyaLaC54an/rTSZcPtRwoXYzF+c7/H3hm8548aLhE73pE2ODCNs6m9Q0h4ALF7Y58V6/ laoQ== |
| X-Received | by 10.42.226.8 with SMTP id iu8mr9309901icb.17.1431528908694; Wed, 13 May 2015 07:55:08 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <06301cb8-39a6-410b-9fad-afe6bd4d3217@googlegroups.com> |
| References | <25ba3a96-21ee-4a83-b7c1-8ac60508d30c@googlegroups.com> <mivmr0$1mb$1@r01.glglgl.de> <06301cb8-39a6-410b-9fad-afe6bd4d3217@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 13 May 2015 08:54:28 -0600 |
| Subject | Re: Basic misunderstanding on object creation |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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.446.1431528916.12865.python-list@python.org> (permalink) |
| Lines | 32 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1431528916 news.xs4all.nl 2845 [2001:888:2000:d::a6]:56672 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90560 |
Show key headers only | View raw
On Wed, May 13, 2015 at 8:42 AM, andrew cooke <andrew@acooke.org> wrote:
> On Wednesday, 13 May 2015 11:36:12 UTC-3, Thomas Rachel wrote:
>> Am 13.05.2015 um 15:25 schrieb andrew cooke:
>>
>> >>>> class Foo:
>> > ... def __new__(cls, *args, **kargs):
>> > ... print('new', args, kargs)
>> > ... super().__new__(cls, *args, **kargs)
>>
>> > new (1,) {}
>> > Traceback (most recent call last):
>> > File "<stdin>", line 1, in <module>
>> > File "<stdin>", line 4, in __new__
>> > TypeError: object() takes no parameters
>>
>> object's __new__() dosn't take any parameters. So call it without arguments:
>>
>> class Foo:
>> def __new__(cls, *args, **kargs):
>> print('new', args, kargs)
>> super().__new__(cls)
>>
>> (at least if we know that we inherit from object. Might be that this one
>> doesn't work very good with multiple inheritance...)
>>
>>
>> Thomas
>
> But then nothing will be passed to __init__ on the subclass.
__init__ is not called by __new__. In the object construction, __new__
is called, and *then* __init__ is called on the result.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Basic misunderstanding on object creation andrew cooke <andrew@acooke.org> - 2015-05-13 06:25 -0700
Re: Basic misunderstanding on object creation Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2015-05-13 16:24 +0200
Re: Basic misunderstanding on object creation andrew cooke <andrew@acooke.org> - 2015-05-13 07:42 -0700
Re: Basic misunderstanding on object creation andrew cooke <andrew@acooke.org> - 2015-05-13 07:45 -0700
Re: Basic misunderstanding on object creation Peter Otten <__peter__@web.de> - 2015-05-13 16:55 +0200
Re: Basic misunderstanding on object creation Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-13 08:55 -0600
Re: Basic misunderstanding on object creation andrew cooke <andrew@acooke.org> - 2015-05-13 08:52 -0700
Re: Basic misunderstanding on object creation Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-13 08:54 -0600
Re: Basic misunderstanding on object creation Terry Reedy <tjreedy@udel.edu> - 2015-05-13 12:36 -0400
Re: Basic misunderstanding on object creation andrew cooke <andrew@acooke.org> - 2015-05-13 11:42 -0700
Re: Basic misunderstanding on object creation Terry Reedy <tjreedy@udel.edu> - 2015-05-13 15:17 -0400
Re: Basic misunderstanding on object creation Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-13 20:45 +0100
Re: Basic misunderstanding on object creation Ned Batchelder <ned@nedbatchelder.com> - 2015-05-13 13:33 -0700
Re: Basic misunderstanding on object creation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-14 11:07 +1000
Re: Basic misunderstanding on object creation Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-13 17:38 +0100
Re: Basic misunderstanding on object creation Terry Reedy <tjreedy@udel.edu> - 2015-05-13 13:05 -0400
Re: Basic misunderstanding on object creation Terry Reedy <tjreedy@udel.edu> - 2015-05-13 13:13 -0400
Re: Basic misunderstanding on object creation Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-13 18:43 +0100
csiph-web