Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7457
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| 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; 'terry': 0.07; 'python': 0.08; 'collections': 0.09; 'dict': 0.09; 'hash': 0.09; 'notation.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'am,': 0.14; 'wrote:': 0.14; 'clash': 0.16; 'keys.': 0.16; 'meanwhile': 0.16; 'notations': 0.16; 'pythonic': 0.16; 'reedy': 0.16; 'underscore': 0.16; 'method.': 0.16; 'things.': 0.16; 'accessible': 0.19; 'jan': 0.20; 'header:In-Reply-To:1': 0.21; 'right.': 0.22; 'skip:[ 10': 0.26; 'classes': 0.26; 'not.': 0.26; 'object': 0.26; 'subject:?': 0.29; 'class': 0.29; "won't": 0.30; 'modules,': 0.30; 'parent': 0.30; 'tuples': 0.30; 'this.': 0.31; 'named': 0.32; 'header:X -Complaints-To:1': 0.32; 'someone': 0.33; 'to:addr:python-list': 0.33; 'thank': 0.35; 'there': 0.35; 'header:User-Agent:1': 0.35; 'yet,': 0.35; 'uses': 0.36; 'received:org': 0.38; 'could': 0.38; 'problem.': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'map': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'really': 0.40; 'you.': 0.62; 'other.': 0.63; 'property': 0.64; 'square': 0.67; 'here.': 0.69; 'examined': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Square bracket and dot notations? |
| Date | Sat, 11 Jun 2011 15:49:36 -0400 |
| References | <4ab9f6bd-cf2d-4c0a-8eda-7d8ffa6bd6c4@v10g2000yqn.googlegroups.com> <801d330e-5610-45a3-ba5d-796e2ec179fe@w10g2000yqh.googlegroups.com> <c50676cd-622b-4c31-95c6-d2e01cd661ec@j23g2000yqc.googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | rain.gmane.org |
| User-Agent | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 |
| In-Reply-To | <c50676cd-622b-4c31-95c6-d2e01cd661ec@j23g2000yqc.googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| 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.135.1307821792.11593.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1307821792 news.xs4all.nl 49046 [::ffff:82.94.164.166]:33138 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7457 |
Show key headers only | View raw
On 6/11/2011 10:40 AM, Asen Bozhilov wrote: > It is exactly what I wanted to know. Thank you. I have not examined > classes in Python yet, but when I do it I will understand some new > things. One of the most interesting is, can an object inherit items > trough the parent class? By items I mean items which are accessible > trough square bracket notation. .attributes are inherited. [index-or-key] items are not. > I really like Pythonic way here. Square bracket and dot notations > allow me to create an object which can be "true" hash map and > meanwhile to support independent methods from its keys. I could have > an item and a property with same names and they won't interfere each > other. Right. d.items is a dict method. d['items'] is whatever you assign. Named tuples in the collections modules, which allow access to fields through .name as well as [index], have the name class problem. All the methods are therefore given leading underscore names to avoid this. [But there still could be a clash if someone used field names with leading underscores!] Python reserves and uses __xxx__ for system names just to avoid clashes. -- Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Square bracket and dot notations? Asen Bozhilov <asen.bozhilov@gmail.com> - 2011-06-11 02:41 -0700
Re: Square bracket and dot notations? Andrew Berg <bahamutzero8825@gmail.com> - 2011-06-11 05:06 -0500
Re: Square bracket and dot notations? Ben Finney <ben+python@benfinney.id.au> - 2011-06-11 20:11 +1000
Re: Square bracket and dot notations? Francesco Bochicchio <bieffe62@gmail.com> - 2011-06-11 03:46 -0700
Re: Square bracket and dot notations? Asen Bozhilov <asen.bozhilov@gmail.com> - 2011-06-11 07:40 -0700
Re: Square bracket and dot notations? Terry Reedy <tjreedy@udel.edu> - 2011-06-11 15:49 -0400
Re: Square bracket and dot notations? Asen Bozhilov <asen.bozhilov@gmail.com> - 2011-06-11 13:41 -0700
csiph-web