Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64075
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rmorgan466@gmail.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; 'python.': 0.02; '16,': 0.03; 'argument': 0.05; 'advocate': 0.07; 'context': 0.07; 'conventions': 0.07; 'patterns.': 0.07; 'advice.': 0.09; 'appropriate.': 0.09; 'constructor': 0.09; 'facts': 0.09; 'specific.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'jan': 0.12; 'called.': 0.16; 'cons': 0.16; 'constructor.': 0.16; 'encountered,': 0.16; 'finney': 0.16; 'garrett': 0.16; 'informally,': 0.16; 'initialiser': 0.16; 'roy': 0.16; 'simpson': 0.16; 'subject:object': 0.16; 'subject:when': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'thu,': 0.19; 'later': 0.20; 'seems': 0.21; 'saying': 0.22; 'cc:addr:python.org': 0.22; "shouldn't": 0.24; 'tend': 0.24; 'cheers,': 0.24; '---': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'define': 0.26; 'first,': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'work.': 0.31; 'commonly': 0.31; 'writes:': 0.31; 'open': 0.33; 'says': 0.33; 'url:python': 0.33; 'everyone': 0.33; "i'd": 0.34; 'problem': 0.35; 'advice': 0.35; 'agree': 0.35; 'classes': 0.35; 'beyond': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'c++': 0.36; 'instances': 0.36; 'largely': 0.36; 'subject:data': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'ben': 0.38; 'depends': 0.38; 'that,': 0.38; 'anything': 0.39; 'does': 0.39; 'bill': 0.39; 'use.': 0.39; 'url:mail': 0.40; 'even': 0.60; 'read': 0.60; 'new': 0.61; 'making': 0.63; 'charset:windows-1252': 0.65; 'smith': 0.68; 'subject': 0.69; 'stated': 0.69; 'mistaken': 0.84; 'out....': 0.84; 'replies.': 0.84 |
| 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:to :cc:content-type; bh=q0cSpwGl7TvjbXfX+JusvaPkTyA1lq8FvwaAJ4KJ6wo=; b=Rwja++RmzJI6jOeBB9ShNfHQxozeyEgpOsNLAeu7ztiTOwbyd8BVqqdMdI1fuYISyu wVkSEjQPqNVs6t0VjB8spBPeCRWRRideS7H7/n6Kz5IySMPvPHkGh5jdrtske+7+Rpqp NTOjuB/mriri2nL6omgvH13ITSXnIUqtsU9hp7kKCHdxqq5UyedgH6hqXeMAwulbTINp /6BIJ5dA6EW6XAdtk2r0u2Lv+GshazJiPHRC8zpAQWWXUqBPNlXDw6HYvXopqUh7pg0i Jxe5E8OSK4uhchjlalNV6kkIiv9Edl/Omq7MnJoHeVvSi3k5/AOK8aJo4SLeZO06FwGf q7eA== |
| MIME-Version | 1.0 |
| X-Received | by 10.182.19.132 with SMTP id f4mr6647648obe.14.1389873678033; Thu, 16 Jan 2014 04:01:18 -0800 (PST) |
| In-Reply-To | <20140116063654.GA23771@cskk.homeip.net> |
| References | <7wha94bk7v.fsf@benfinney.id.au> <20140116063654.GA23771@cskk.homeip.net> |
| Date | Thu, 16 Jan 2014 07:01:17 -0500 |
| Subject | Re: data validation when creating an object |
| From | Rita <rmorgan466@gmail.com> |
| To | Cameron Simpson <cs@zip.com.au> |
| Content-Type | multipart/alternative; boundary=001a11c2aa6adca82b04f0152e68 |
| Cc | "python-list@python.org" <python-list@python.org> |
| 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.5584.1389873681.18130.python-list@python.org> (permalink) |
| Lines | 150 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389873681 news.xs4all.nl 2858 [2001:888:2000:d::a6]:37159 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64075 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Thanks everyone for the replies. On Thu, Jan 16, 2014 at 1:36 AM, Cameron Simpson <cs@zip.com.au> wrote: > On 16Jan2014 15:53, Ben Finney <ben+python@benfinney.id.au> wrote: > > Roy Smith <roy@panix.com> writes: > > > Ben Finney <ben+python@benfinney.id.au> wrote: > > > > Who says it's frowned on to do work in the initialiser? Where are > they > > > > saying it? That seems over-broad, I'd like to read the context of > that > > > > advice. > > > > > > There are some people who advocate that C++ constructors should not do > > > a lot of work and/or should be incapable of throwing exceptions. The > > > pros and cons of that argument are largely C++ specific. […] > > > > Even simpler: They are mistaken in what the constructor is named, in > > Python. > > Python classes have the constructor, ‘__new__’. I would agree with > > advice not to do anything but allocate the resources for a new instance > > in the constructor. [...] > > > > Python instances have an initialiser, ‘__init__’. That function is for > > setting up the specific instance for later use. This is commonly > > over-ridden and many classes define a custom initialiser, which normally > > does some amount of work. > > > > I don't think ‘__init__’ is subject to the conventions of a constructor, > > because *‘__init__’ is not a constructor*. > > 99% of the time this distinction is moot. When I call ClassName(blah,...), > both the constructor and initialiser are called. > > Informally, there's a rule of thumb that making an object (allocate, > construct and initialise) shouldn't be needlessly expensive. Beyond > that, what happens depends on the use patterns. > > This rule of thumb will be what Rita's encountered, perhaps stated > without any qualification regarding what's appropriate. > > Cheers, > -- > Cameron Simpson <cs@zip.com.au> > > The problem with keeping an open mind is that my ideas all tend to fall > out... > - Bill Garrett <garrett@cs.unc.edu> > -- > https://mail.python.org/mailman/listinfo/python-list > -- --- Get your facts first, then you can distort them as you please.--
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: data validation when creating an object Rita <rmorgan466@gmail.com> - 2014-01-16 07:01 -0500
csiph-web