Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65205
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| 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; 'python.': 0.02; '(except': 0.07; 'initialize': 0.07; '__init__': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'method,': 0.09; '~ethan~': 0.09; 'python': 0.11; '[1].': 0.16; '__new__': 0.16; 'behavior,': 0.16; 'cls': 0.16; 'enum': 0.16; 'it),': 0.16; 'kitchen': 0.16; 'old-style': 0.16; 'recipes': 0.16; 'stuff.': 0.16; 'two,': 0.16; 'sat,': 0.16; 'wrote:': 0.18; '(where': 0.19; 'foundation,': 0.20; 'feb': 0.22; 'header:User-Agent:1': 0.23; '(or': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; '[1]': 0.29; 'along': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'quite': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'could': 0.34; 'basic': 0.35; 'classes': 0.35; 'there': 0.35; 'done': 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'easily': 0.37; 'being': 0.38; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'how': 0.40; 'received:173': 0.61; 'further': 0.61; 'useful.': 0.68; 'behavior': 0.77 |
| Date | Sat, 01 Feb 2014 00:28:03 -0800 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: __init__ is the initialiser |
| References | <lcgtpf$tui$1@ger.gmane.org> <mailman.6217.1391197950.18130.python-list@python.org> <52ec6d1f$0$29972$c3e8da3$5496439d@news.astraweb.com> <mailman.6255.1391229320.18130.python-list@python.org> <52ec8b51$0$29972$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <52ec8b51$0$29972$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset=us-ascii; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - gator3304.hostgator.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - stoneleaf.us |
| X-BWhitelist | no |
| X-Source-IP | 173.12.184.233 |
| X-Source | |
| X-Source-Args | |
| X-Source-Dir | |
| X-Source-Sender | ([173.12.184.233]) [173.12.184.233]:37457 |
| X-Source-Auth | ethan+stoneleaf.us |
| X-Email-Count | 1 |
| X-Source-Cap | dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= |
| 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.6271.1391244676.18130.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1391244676 news.xs4all.nl 2937 [2001:888:2000:d::a6]:46862 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:65205 |
Show key headers only | View raw
On 01/31/2014 09:51 PM, Steven D'Aprano wrote: > On Sat, 01 Feb 2014 15:35:17 +1100, Chris Angelico wrote: >> >> The two methods could have been done as a single method, __construct__, >> in which you get passed a cls instead of a self, and you call >> self=super().__construct__() and then initialize stuff. > > That would be called __new__ in Python. There's no *need* to use __init__ > for anything (except old-style classic classes in Python 2). While there may not be a /need/ for two, having two is quite handy. Having __new__ take care of the nuts and bolts (or foundation, as Terry put it), and being able to further customize with __init__ (where the kitchen goes, how many bedrooms, to follow along with Terry) is quite useful. One of my favorite Enum recipes uses that pattern to have some basic behavior, with some other behavior that is easily overridable/extendable [1]. -- ~Ethan~ [1] http://stackoverflow.com/q/19330460/208880
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: __init__ is the initialiser Ned Batchelder <ned@nedbatchelder.com> - 2014-01-31 14:52 -0500
Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-01 03:42 +0000
Re: __init__ is the initialiser Chris Angelico <rosuav@gmail.com> - 2014-02-01 15:35 +1100
Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-01 05:51 +0000
Re: __init__ is the initialiser Ethan Furman <ethan@stoneleaf.us> - 2014-02-01 00:28 -0800
Re: __init__ is the initialiser Ethan Furman <ethan@stoneleaf.us> - 2014-01-31 20:55 -0800
Re: __init__ is the initialiser Ned Batchelder <ned@nedbatchelder.com> - 2014-02-01 07:28 -0500
Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-01 09:40 -0500
Re: __init__ is the initialiser Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-01 15:07 +0000
Re: __init__ is the initialiser Roy Smith <roy@panix.com> - 2014-02-01 11:17 -0500
Re: __init__ is the initialiser Tim Delaney <timothy.c.delaney@gmail.com> - 2014-02-02 07:09 +1100
Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-02 01:28 +0000
Re: __init__ is the initialiser Ben Finney <ben+python@benfinney.id.au> - 2014-02-02 15:27 +1100
Re: __init__ is the initialiser Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-03 12:38 +1300
Re: __init__ is the initialiser Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-03 00:33 +0000
Re: __init__ is the initialiser Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-04 12:47 +1300
Re: __init__ is the initialiser Tim Delaney <timothy.c.delaney@gmail.com> - 2014-02-03 11:02 +1100
csiph-web