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


Groups > comp.lang.python > #7442

Re: Square bracket and dot notations?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!teal.octanews.net!news-out.octanews.net!indigo.octanews.net!news.glorb.com!news.astraweb.com!border6.newsrouter.astraweb.com!not-for-mail
From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: Square bracket and dot notations?
References <4ab9f6bd-cf2d-4c0a-8eda-7d8ffa6bd6c4@v10g2000yqn.googlegroups.com>
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
Date Sat, 11 Jun 2011 20:11:17 +1000
Message-ID <87fwngvfsq.fsf@benfinney.id.au> (permalink)
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)
Cancel-Lock sha1:t7dd0reKHpK93kBUSwruoAJowCo=
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Lines 33
Organization Unlimited download news at news.astraweb.com
NNTP-Posting-Host 1ade2e95.news.astraweb.com
X-Trace DXC=SgV2<`KImIQ?W?WaA<e5APL?0kYOcDh@ZW\:Hm@YlDbZ=Tj0X3JjUAZUGD@iN[Hd?_G9^2@OhZc:W
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7442

Show key headers only | View raw


Asen Bozhilov <asen.bozhilov@gmail.com> writes:

> I am beginner in Python. What is interesting for me is that Python
> interpreter treats in different way dot and square bracket notations.
> I am coming from JavaScript where both notations lead prototype chain
> lookup.

Run, don't walk, to the Python Tutorial. Work through each section, do
the examples, experiement to get an understanding of the examples, and
then continue.

    <URL:http://docs.python.org/tutorial/>

> In Python it seems square bracket and dot notations lead lookup in
> different "store".

That's right. Square bracket syntax accesses an object's items, dot
syntax accesses an object's attributes.

> Anyway, I would like to know more about the lookup for key of dict and
> lookup for property of any object with dot notation. Any materials and
> explanations are highly appreciated.

Work through the tutorial from beginning to end to get a good grounding
in this and other fundamentals.

Welcome to the language, and enjoy your learning!

-- 
 \        “Most people, I think, don't even know what a rootkit is, so |
  `\     why should they care about it?” —Thomas Hesse, Sony BMG, 2006 |
_o__)                                                                  |
Ben Finney

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


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