Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107725
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Differences between Class(Object) and Class(Dict) for dictionary usage? |
| Date | Wed, 27 Apr 2016 08:33:40 -0600 |
| Lines | 20 |
| Message-ID | <mailman.149.1461767662.32212.python-list@python.org> (permalink) |
| References | <5720357B.4060009@icloud.com> <CALwzidn0SN5yax3bfmTPDTxBvfr+bnVNzeUe3dZYrS9ji2WCtw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de tTEdWAxWZX9nf5OpboeTzAJ7YRC/IdSMwbyu7dNqI2bg== |
| 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.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'received:209.85.223': 0.03; 'essentially': 0.04; 'attributes': 0.07; 'line:': 0.07; 'subject:Object': 0.09; 'def': 0.13; '2016': 0.16; 'distinction': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:between': 0.16; 'subject:usage': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.24; 'equivalent': 0.27; 'message- id:@mail.gmail.com': 0.27; 'looks': 0.29; 'regardless': 0.31; 'skip:_ 10': 0.32; 'subject:) ': 0.32; 'class': 0.33; 'definition': 0.34; 'tue,': 0.34; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'inherit': 0.66; '26,': 0.72; 'dict,': 0.84; 'dict.': 0.84; 'to:name:python': 0.84; 'subject:Class': 0.91 |
| 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; bh=uYq+/zXu7x5nxHzXZIMt8sn8wo+hZI7BbGYJcN3hklA=; b=A7MZhscHeWPPnutR4i5xBt03XoEd9IqiHdd3ywILcx8a4lK+UsRnbAQme70mD1nOIm chCwxbNKmtrhkMusfDx1DKuAkx9BjLlhwt3IabGMaNZcZKcxaqgto5u3K1jUGAligiy8 fn4Xo5OCFP0Chn+sfSlcOsAnf+h2Zj2fuT4hJ2sdSTqxImyjocjlEAHClXHxrIQedzby M6PRDbt4Ck3noaynoxkc9a5oxFUglcdMnWeHS3uCDJiDU2pT9BlrSf+fnVG0XuiSpL2k KQ1TuYUxGdIdMGTQxuEQjIkbqKGURh9F/3A3rtILtdhxa1mzk7bqrvGXC0dCvvZyOpSh dbQw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=uYq+/zXu7x5nxHzXZIMt8sn8wo+hZI7BbGYJcN3hklA=; b=L4qekwwjSGYpGlMlZfVe9UtAjEDbQcSj49dd3ptncrMMvWIoAjl1zzi59Hi8OrBGkE w/9VM+MyNbAcXA2S1wnYUDJJyDMdfVPgUbO/L6tiQhkEczgE1p38rXjg5FY48z2IeQw5 vErHh8rNAaR18r3cViH441f3/g/eiA0W+ouqyq8vFS09hIj3Gwy0/hx0HiNiwJqzjX1X veJG0hAZoIH5SGWf6FVYRqJMaPQVMiKJ5SAjob0oBoRGd4BnKU3efxzXxQjqKgn/9EX2 UGz6HjUPnS/NFDoXKGKcrMCJtmwu9pDRru8ADFF2b9i3+LF0aj4Fp0CZMbQujtDKozHn ddMA== |
| X-Gm-Message-State | AOPr4FVec54MVlfP1OAmwwaAo/aIE3wcmcbLCyeFR2Mwq0sXl9eUMYG04hWhljG6mIJGcnVe44g5MCD/2zd9tA== |
| X-Received | by 10.107.19.148 with SMTP id 20mr11878677iot.11.1461767660105; Wed, 27 Apr 2016 07:34:20 -0700 (PDT) |
| In-Reply-To | <5720357B.4060009@icloud.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 | <CALwzidn0SN5yax3bfmTPDTxBvfr+bnVNzeUe3dZYrS9ji2WCtw@mail.gmail.com> |
| X-Mailman-Original-References | <5720357B.4060009@icloud.com> |
| Xref | csiph.com comp.lang.python:107725 |
Show key headers only | View raw
On Tue, Apr 26, 2016 at 9:43 PM, Christopher Reimer
<christopher_reimer@icloud.com> wrote:
> class Test2(dict):
> def __init__(self):
> self.__dict__ = {'key', 'value'}
This class definition looks muddled. Because Test2 inherits from dict,
the object referred to by "self" will be a dict, and self.__dict__ is
actually a *different* dict, containing the attributes of self. The
line:
self.__dict__ = {'key', 'value'}
is essentially equivalent to:
self.key = value
and will be regardless of whether you inherit from object or dict. If
you find this distinction confusing, then I recommend not inheriting
from dict.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Differences between Class(Object) and Class(Dict) for dictionary usage? Ian Kelly <ian.g.kelly@gmail.com> - 2016-04-27 08:33 -0600
csiph-web