Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64382
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '21,': 0.07; 'args': 0.07; '(self,': 0.09; '*args,': 0.09; '__init__': 0.09; 'cc:addr:python- list': 0.11; 'def': 0.12; 'jan': 0.12; '**kwargs)': 0.16; '**kwargs):': 0.16; 'charles': 0.16; 'dict': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; '(or': 0.24; 'cc:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'skip:_ 10': 0.34; 'created': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'instances': 0.36; 'work?': 0.38; 'read': 0.60; 'simply': 0.61; 'dict()': 0.84; 'dict.': 0.84; 'itself?': 0.84; 'to:none': 0.92 |
| 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:cc :content-type; bh=yHidu5Zn5etlK6bwbVAWA6wXJrpaG0Nqeyv5CBcld6A=; b=ASt4jwpgaJc8s8wFoN1cBZ7mka5GezUNBcNyLjY4+ylCXbvCTA9ouPKFr/XadDA2Bm IBFLzYfVkeZt8dafWId1hDma9sD0P7912ab8UQQSgVIVynGIB/RqQ10g7pjxWaWf6aeO 4RwxF7WI4sEk6W4X3tF9It8JKwVarACUZUAtvIwQ3SdJQX6Z0mBHCWdlb7lKbHacO4u9 ymC8ZTge0O2ENtb0KBEV5HlT5r1Un4gZTvRaIEO48bNxhxMLqlo4kRelwGtQAWhIvtGg hx0f9uBPWSYNtLgxwZtL9+pmC5ISsqIjSH5WEDnNSUhaSd+BDGvgba/INMt16/HDfgI0 KDmw== |
| MIME-Version | 1.0 |
| X-Received | by 10.66.102.39 with SMTP id fl7mr21150924pab.43.1390262912117; Mon, 20 Jan 2014 16:08:32 -0800 (PST) |
| In-Reply-To | <52DD8297.9050504@earthlink.net> |
| References | <52DD8297.9050504@earthlink.net> |
| Date | Tue, 21 Jan 2014 11:08:32 +1100 |
| Subject | Re: 1st Sketch at at ReadOnly dict |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.5765.1390262921.18130.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1390262921 news.xs4all.nl 2911 [2001:888:2000:d::a6]:46291 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:64382 |
Show key headers only | View raw
On Tue, Jan 21, 2014 at 7:09 AM, Charles Hixson
<charleshixsn@earthlink.net> wrote:
> # @note Instances can be created only from existing dicts.
>
> ## Class initializer.
> # @param ddict The data dictionary to which this is a read only
> # access.
> # @throws TypeError if ddict is not a dict.
> def __init__ (self, ddict = {}):
> if not isinstance(ddict, dict):
> raise TypeError("ddict must be a dict. It is " +
> repr(ddict))
> self._ddict = ddict
Instead of demanding that a dict (or dict subclass) be passed, why not
simply pass all args on to dict() itself? Is there a reason this won't
work?
def __init__(self, *args, **kwargs):
self._ddict = dict(*args, **kwargs)
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: 1st Sketch at at ReadOnly dict Chris Angelico <rosuav@gmail.com> - 2014-01-21 11:08 +1100
csiph-web