using __getitem()__ correctly

Charles T. Smith cts.private.yahoo at gmail.com
Wed Dec 30 18:18:58 EST 2015


On Thu, 31 Dec 2015 10:13:53 +1100, Ben Finney wrote:

> "Charles T. Smith" <cts.private.yahoo at gmail.com> writes:
> 
>> I don't understand this distinction between an "attribute" and a "dict
>> item".
> 
> When did you most recently work through the Python tutorial
> <URL:https://docs.python.org/3/tutorial/>> You may want to work through
> it again, from start to finish and exercising each example, to be sure
> you have a solid understanding of basic concepts like these.
> 
> In brief: Objects have attributes; looking up an attribute on an object
> has specific syntax. Dictionaries are collections of items; the items
> are looked up by key, using a quite different syntax. Those two
> different syntaxes translate to distinct special methods.
> 
> You may be familiar with other languages where the distinction between
> “attribute of an object” is not distinct from “item in a dictionary”.
> Python is not one of those languages; the distinction is real and
> important. You'll need to do some remedial learning of Python, and I
> recommend working through the Python tutorial.


Thanks, Ben, for your advice.  Actually, I think that Ian and Chris and
I are making fine progress.  I think you misread my question.



More information about the Python-list mailing list