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


Groups > comp.lang.python > #107666

Re: def __init__(self):

Path csiph.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail
From Random832 <random832@fastmail.com>
Newsgroups comp.lang.python
Subject Re: def __init__(self):
Date Tue, 26 Apr 2016 12:26:07 -0400
Lines 12
Message-ID <mailman.114.1461687970.32212.python-list@python.org> (permalink)
References <34e51ef5-9679-40ec-bc8f-47981353e9d7@googlegroups.com> <571F1361.3010402@digipen.edu> <85eg9sn7qo.fsf@benfinney.id.au> <mailman.100.1461656092.32212.python-list@python.org> <87lh40pyik.fsf@elektro.pacujo.net> <571f9362$0$1602$c3e8da3$5496439d@news.astraweb.com> <1461687967.2507874.590200129.102244C8@webmail.messagingengine.com>
Mime-Version 1.0
Content-Type text/plain
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de ex93OttTxfn4cHxNlLVGewRyPjpq5VkYfiMSXku22RgQ==
Return-Path <random832@fastmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '(of': 0.07; 'override': 0.07; 'immutable': 0.09; 'instance.': 0.09; 'received:internal': 0.09; '(rather': 0.16; '__new__': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'overriding': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'subclassing': 0.16; 'subject:def': 0.16; 'wrote:': 0.16; 'python?': 0.18; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'define': 0.27; 'class': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'tue,': 0.34; 'instance': 0.35; 'possible': 0.36; 'to:addr:python- list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.40; 'header:Message- Id:1': 0.61; 'more': 0.63; '26,': 0.72; 'obvious': 0.76; 'construct': 0.84; 'subject:self': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=z446C/2mRB374q7j59l7qo5jsPM=; b=xyXdy+ KMXHfCop5b99eydohXlEM2D5/xcWKBvnPMipyQMy0tDjGrc5R8Pm/g5F7I+adgNS XSNofOvXJpKMIXK9iOh+EUWHhJA1EsdyMzw4eJGwUMy2Wrz4ZlrQu55hDhTAP6x/ zFFhqJIfNvpEohoMjUER4kkv1m/4dWi3kppjI=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=z446C/2mRB374q7 j59l7qo5jsPM=; b=DGIKAcPHtkUeYQxDhwi4M88R/U7pkDnXUhI4oI9GIJpESBV xQ4jxJ9IidWcuwlyjj6dlSuZ2uVKMm5YQnMcwz6cVYJijUivNfMKLzIc7NHKFYJ6 9VTVDx3f0OWTxLtOssr2xD5HC329A6opqBKgxZ6tQtmoN5yGGgHrkBMQ+MpA=
X-Sasl-Enc h16RJkcVvdN1d0eTmSO74GA3HXqZwcgu6fx+AzvS3QnT 1461687967
X-Mailer MessagingEngine.com Webmail Interface - ajax-b462e126
In-Reply-To <571f9362$0$1602$c3e8da3$5496439d@news.astraweb.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <1461687967.2507874.590200129.102244C8@webmail.messagingengine.com>
X-Mailman-Original-References <34e51ef5-9679-40ec-bc8f-47981353e9d7@googlegroups.com> <571F1361.3010402@digipen.edu> <85eg9sn7qo.fsf@benfinney.id.au> <mailman.100.1461656092.32212.python-list@python.org> <87lh40pyik.fsf@elektro.pacujo.net> <571f9362$0$1602$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:107666

Show key headers only | View raw


On Tue, Apr 26, 2016, at 12:12, Steven D'Aprano wrote:
> The obvious reason for overriding __new__ is to construct an immutable
> instance. You have to override __new__, because by the time it returns
> the
> instance is immutable and you can no longer initialise it.

Other than by subclassing an existing immutable type written in C, is it
actually possible to define a truly-immutable (rather than
contract-immutable) class in python?

(Of course, subclassing immutable C types is the more obvious answer to
when you have to override __new__).

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


Thread

def __init__(self): San <santanu01@gmail.com> - 2016-04-25 23:21 -0700
  Re: def __init__(self): Ben Finney <ben+python@benfinney.id.au> - 2016-04-26 16:31 +1000
  Re: def __init__(self): Gary Herron <gherron@digipen.edu> - 2016-04-26 00:06 -0700
  Re: def __init__(self): Ben Finney <ben+python@benfinney.id.au> - 2016-04-26 17:34 +1000
    Re: def __init__(self): Marko Rauhamaa <marko@pacujo.net> - 2016-04-26 11:25 +0300
      Re: def __init__(self): Steven D'Aprano <steve@pearwood.info> - 2016-04-27 02:12 +1000
        Re: def __init__(self): Random832 <random832@fastmail.com> - 2016-04-26 12:26 -0400
          Re: def __init__(self): Steven D'Aprano <steve@pearwood.info> - 2016-04-27 02:32 +1000
            Re: def __init__(self): Chris Kaynor <ckaynor@zindagigames.com> - 2016-04-26 09:59 -0700
              Re: def __init__(self): Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-04-27 14:54 +1000
            Re: def __init__(self): Chris Angelico <rosuav@gmail.com> - 2016-04-27 03:04 +1000
            Re: def __init__(self): Chris Kaynor <ckaynor@zindagigames.com> - 2016-04-26 10:13 -0700
            Re: def __init__(self): Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-26 11:26 -0600
            Re: def __init__(self): Chris Angelico <rosuav@gmail.com> - 2016-04-27 03:30 +1000
        Re: def __init__(self): Marko Rauhamaa <marko@pacujo.net> - 2016-04-26 19:38 +0300
  Re: def __init__(self): Random832 <random832@fastmail.com> - 2016-04-26 09:49 -0400
  Re: def __init__(self): Gary Herron <gherron@digipen.edu> - 2016-04-26 07:25 -0700

csiph-web