Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107703
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Christopher Reimer <christopher_reimer@icloud.com> |
| Newsgroups | comp.lang.python |
| Subject | Differences between Class(Object) and Class(Dict) for dictionary usage? |
| Date | Tue, 26 Apr 2016 20:43:55 -0700 |
| Lines | 24 |
| Message-ID | <mailman.138.1461728646.32212.python-list@python.org> (permalink) |
| References | <5720357B.4060009@icloud.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de NcTu4op511a5vAAKi7F+Sw1x060lKaEoZoCXWXIW7Itg== |
| Return-Path | <christopher_reimer@icloud.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.090 |
| X-Spam-Evidence | '*H*': 0.82; '*S*': 0.00; 'subject:Object': 0.09; 'def': 0.13; 'variables': 0.15; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:between': 0.16; 'subject:usage': 0.16; 'variable': 0.18; 'code.': 0.23; 'seems': 0.23; "haven't": 0.24; 'discussion': 0.24; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'object,': 0.27; 'received:17': 0.27; 'values': 0.28; 'dictionary': 0.29; "i'm": 0.30; 'skip:_ 10': 0.32; 'received:10.0.0': 0.32; 'subject:) ': 0.32; 'class': 0.33; 'received:10.0': 0.34; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'received:10': 0.37; 'seem': 0.37; 'difference': 0.38; 'thank': 0.38; 'to:addr:python.org': 0.40; 'header:MIME- version:1': 0.60; 'greetings,': 0.61; 'great': 0.63; 'other.': 0.64; 'internet': 0.70; 'or:': 0.84; 'approach.': 0.91; 'played': 0.91; 'subject:Class': 0.91 |
| X-Proofpoint-Virus-Version | vendor=fsecure engine=2.50.10432:,, definitions=2016-04-27_02:,, signatures=0 |
| X-Proofpoint-Spam-Details | rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1604270053 |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=4d515a; t=1461728636; bh=E+60AFhVP0fOem3HcUwGSSVjFJeTYGMo2yOZSZCNIaY=; h=To:From:Subject:Message-id:Date:MIME-version:Content-type; b=Da00riVZ8HreMIIw3eN8hQO/G9N6hWXaKpHCbtU0bcR/4+FZZrPN+Zz5kJVKdqU6b syUmJY1V9QiAu86DxUhKQZvZ+aXw+9Ajl6cGweU0MtG5TxPpK+gJOOU0GLHChJzi4/ 41W/TW3Ax6t6HqFs/0l30lsJauFOYujzZtN7Xet9vqfCRWlap2G08QGdPLzyEsq/Ix SXF6y/sBaM4+DdQ6xytko5f0XvqNqM9c6TnU64Eytn78D7UaHVTdMTZbvGZn3MlxB/ 7B9TCbYblfVjbyXvzuY+bPTb6ZvtnSXqzZ4nm3wGpHN1IOAwEHq4SVAQsPjVMEPtvC 2LhTG5CSJ+sJg== |
| 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 | <5720357B.4060009@icloud.com> |
| Xref | csiph.com comp.lang.python:107703 |
Show key headers only | View raw
Greetings,
If I'm using a dictionary to store variables for an object, and
accessing the variable values from dictionary via property decorators,
would it be better to derive the class from object or dict?
class Test1(object):
def __init__(self):
self.state = {'key': 'value'}
Or:
class Test2(dict):
def __init__(self):
self.__dict__ = {'key', 'value'}
I haven't seen a good pro/con discussion on the Internet for using one
over the other. I played with both in my code. Doesn't seem to make a
great difference either way. Using object seems to be the most simplest
approach.
Thank you,
Chris R.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Differences between Class(Object) and Class(Dict) for dictionary usage? Christopher Reimer <christopher_reimer@icloud.com> - 2016-04-26 20:43 -0700
csiph-web