Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107745

Re: Pythonic style (was: Differences between Class(Object) and Class(Dict) for dictionary usage?)

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Christopher Reimer <christopher_reimer@icloud.com>
Newsgroups comp.lang.python
Subject Re: Pythonic style (was: Differences between Class(Object) and Class(Dict) for dictionary usage?)
Date Wed, 27 Apr 2016 20:07:31 -0700
Lines 19
Message-ID <mailman.163.1461812854.32212.python-list@python.org> (permalink)
References <5720357B.4060009@icloud.com> <CALwzidn0SN5yax3bfmTPDTxBvfr+bnVNzeUe3dZYrS9ji2WCtw@mail.gmail.com> <572166FA.3020108@icloud.com> <85y47yjxj5.fsf_-_@benfinney.id.au> <57217E73.9040907@icloud.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8BIT
X-Trace news.uni-berlin.de zOjgzGqhcp9VVd81ckIRoAonrDyvYKSvYbdnmGkSvDbg==
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.028
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:Object': 0.09; 'python': 0.10; 'subject: \n ': 0.15; '7:07': 0.16; 'attributes,': 0.16; 'conveys': 0.16; 'dictionary.': 0.16; 'magic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:?)': 0.16; 'subject:between': 0.16; 'subject:usage': 0.16; 'syntactic': 0.16; 'terms).': 0.16; 'wrote:': 0.16; 'latter': 0.22; 'header:User- Agent:1': 0.26; 'chris': 0.26; 'separate': 0.27; 'received:17': 0.27; 'invoke': 0.29; 'short,': 0.29; 'code': 0.30; 'received:10.0.0': 0.32; 'subject:) ': 0.32; 'received:10.0': 0.34; 'behind': 0.35; 'instead': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'say': 0.37; 'turned': 0.38; 'thank': 0.38; 'to:addr:python.org': 0.40; 'header:MIME-version:1': 0.60; 'more': 0.63; '8bit%:21': 0.70; 'skip:\xe2 10': 0.70; '8bit%:43': 0.72; "(don't": 0.84; 'expresses': 0.84; 'header:In-reply-to:1': 0.84; 'subject:Class': 0.91
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:,, definitions=2016-04-28_01:,, 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-1604280043
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2
In-reply-to <85y47yjxj5.fsf_-_@benfinney.id.au>
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=4d515a; t=1461812852; bh=CrPNKU4xkv6XH3pVuiZZFku54NBanRwvSKXH4pqbpJk=; h=MIME-version:Content-type:Subject:To:From:Message-id:Date; b=C7gKfYN6tyhhxVtvO9ZfoDw+nITGPDjg7CVpAZcz0hIber3oAe6+RLIzPL0WIP9cq EA5xrYmFHprs0F3qlFNqAaANTscKYV1iCs666O2716mTrLj2Hy7zW7Q9b7fIfaRP8t ln/2BjVj8T+/EieY4NqeatUYXt03yfP9eLUJOF4QKq4MZmRCBqBlV5RLxMFhHenZb0 n/3dXlWC5cBczp7zd9EU/UCrwV4vDBQsfIz9fhvweUnuawmUVlVCoN8EGhwbgkmeco 0HVhcGTkMPXx/DDCIIzv+N6Co6NU4NMWjdpuVN/GGZ4rCMRU2iVYm8Q8gevuDbssBX f8c0o+T+MaXMg==
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 <57217E73.9040907@icloud.com>
X-Mailman-Original-References <5720357B.4060009@icloud.com> <CALwzidn0SN5yax3bfmTPDTxBvfr+bnVNzeUe3dZYrS9ji2WCtw@mail.gmail.com> <572166FA.3020108@icloud.com> <85y47yjxj5.fsf_-_@benfinney.id.au>
Xref csiph.com comp.lang.python:107745

Show key headers only | View raw


On 4/27/2016 7:07 PM, Ben Finney wrote:
> I would say the latter is more Pythonic, because it:
>
> * Better conveys the intention (“set the value of the ‘self.key’
>    attribute”).
>
> * Uses the built-in mechanisms of Python (don't invoke magic attributes,
>    instead use the system that makes use of them behind the scenes).
>
> * Expresses that intention more concisely (fewer terms).
>
> * Expresses that intention more clearly (less syntactic noise).

In short,  my original code before I turned it into a separate 
dictionary. *sigh*

Thank you,

Chris R.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Pythonic style (was: Differences between Class(Object) and Class(Dict) for dictionary usage?) Christopher Reimer <christopher_reimer@icloud.com> - 2016-04-27 20:07 -0700

csiph-web