Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101023
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: using __getitem()__ correctly |
| Date | 2015-12-31 10:13 +1100 |
| Message-ID | <mailman.92.1451517241.11925.python-list@python.org> (permalink) |
| References | (2 earlier) <n60qcp$rtp$2@dont-email.me> <mailman.76.1451489799.11925.python-list@python.org> <n612fj$rtp$4@dont-email.me> <mailman.83.1451508086.11925.python-list@python.org> <n61nbh$rtp$5@dont-email.me> |
"Charles T. Smith" <cts.private.yahoo@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. -- \ “But it is permissible to make a judgment after you have | `\ examined the evidence. In some circles it is even encouraged.” | _o__) —Carl Sagan, _The Burden of Skepticism_, 1987 | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-30 12:57 +0000
Re: using __getitem()__ correctly Chris Angelico <rosuav@gmail.com> - 2015-12-31 00:11 +1100
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-30 14:40 +0000
Re: using __getitem()__ correctly Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-30 08:35 -0700
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-30 16:58 +0000
Re: using __getitem()__ correctly Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-30 13:40 -0700
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-30 22:54 +0000
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-30 22:58 +0000
Re: using __getitem()__ correctly Ben Finney <ben+python@benfinney.id.au> - 2015-12-31 10:13 +1100
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-30 23:18 +0000
Re: using __getitem()__ correctly Steven D'Aprano <steve@pearwood.info> - 2015-12-31 10:50 +1100
Re: using __getitem()__ correctly Ben Finney <ben+python@benfinney.id.au> - 2015-12-31 11:21 +1100
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-31 11:30 +0000
Re: using __getitem()__ correctly Ben Finney <ben+python@benfinney.id.au> - 2015-12-31 22:51 +1100
Re: using __getitem()__ correctly Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-12-31 12:12 +0000
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-31 13:39 +0000
Re: using __getitem()__ correctly Steven D'Aprano <steve@pearwood.info> - 2016-01-01 02:03 +1100
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-31 11:17 +0000
Re: using __getitem()__ correctly Steven D'Aprano <steve@pearwood.info> - 2016-01-01 01:43 +1100
Re: using __getitem()__ correctly Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-30 17:31 -0700
Re: using __getitem()__ correctly "Charles T. Smith" <cts.private.yahoo@gmail.com> - 2015-12-31 12:45 +0000
csiph-web