Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34657
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cameron@cskk.homeip.net> |
| 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; 'attribute': 0.05; 'attributes': 0.07; 'dict': 0.09; 'meaningful': 0.09; 'subclasses': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.10; '(also': 0.16; 'compromise': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'ian.': 0.16; 'keys.': 0.16; 'lowercase': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:edu.au': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'simpson': 0.16; 'subclassing': 0.16; 'subject: \n ': 0.16; 'trash': 0.16; 'uppercase': 0.16; 'wrote:': 0.17; '>>>': 0.18; 'mostly': 0.20; 'keys': 0.22; 'names.': 0.22; 'cheers,': 0.23; 'cc:2**0': 0.23; 'work.': 0.23; 'elements': 0.23; 'this:': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'bugs': 0.27; 'rest': 0.28; 'noticed': 0.28; 'post': 0.28; 'dictionary': 0.29; 'class': 0.29; 'code': 0.31; 'december': 0.32; 'running': 0.32; 'could': 0.32; 'anyone': 0.33; '(with': 0.33; 'fail': 0.35; 'mapping': 0.35; 'but': 0.36; 'received:au': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'think': 0.40; 'decision': 0.60; 'content- disposition:inline': 0.60; 'map': 0.61; 'kind': 0.61; 'free': 0.61; 'land': 0.62; 'effective': 0.63; 'special': 0.73; "'now'": 0.84; 'easier,': 0.84; 'ocean': 0.84 |
| Date | Wed, 12 Dec 2012 09:31:22 +1100 |
| From | Cameron Simpson <cs@zip.com.au> |
| To | Dave Cinege <dave@linkscape.net> |
| Subject | Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| In-Reply-To | <201212111557.24851.dave@linkscape.net> |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| References | <201212111557.24851.dave@linkscape.net> |
| Cc | 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.750.1355265569.29569.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1355265569 news.xs4all.nl 6876 [2001:888:2000:d::a6]:51089 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:34657 |
Show key headers only | View raw
On 11Dec2012 15:57, Dave Cinege <dave@linkscape.net> wrote: | On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote: | > running into bugs like this: | > >>> thes = Thesaurus() | > >>> thes.update = 'now' | > >>> thes.update | > | > <built-in method update of Thesaurus object at 0x01DB30C8> | | I've noticed this but it's mostly pointless, as meaningful code does work. | (Also you stepped on the existing 'update()' dictionary method.) I think that was a deliberate choice of name by Ian. I've got a class like Thesaurus that subclasses dict and maps attributes to dictionary elements (with a few special purpose tweaks I could go into if anyone cares). I made a deliberate decision to only map UPPERCASE attributes to dict keys to avoid exactly the kind of conflict above, because: thes.update = 'now' must either trash the dict.update method _or_ fail to present .update as 'now'. Both have their downsides. So at the cost of shoutier but still effective code I accepted only .UPPERCASE attribute names as mapping to keys. This compromise also makes subclassing much easier, because the subclasser is free to use conventional lowercase attribute names. Cheers, -- Cameron Simpson <cs@zip.com.au> Thousands at his bidding speed, And post o'er land and ocean without rest - Milton
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Cameron Simpson <cs@zip.com.au> - 2012-12-12 09:31 +1100
csiph-web