non-owning references?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Jul 25 09:37:51 EDT 2009
On Sat, 25 Jul 2009 04:45:48 -0700, Carl Banks wrote:
> On Jul 24, 8:14 am, Ben Finney <ben+pyt... at benfinney.id.au> wrote:
>> Hrvoje Niksic <hnik... at xemacs.org> writes:
>> > The term "variable" is used in the Python language reference and
>> > elsewhere
>>
>> Yes. It should also be abundantly clear from the constant stream of
>> confused newbies on this point that its usage of that term is different
>> to what many expect from usage elsewhere.
>
> Personally, I haven't noticed a constant stream, just a few here and
> there.
>
> I expect that someone used to C variables will expect Python variables
> to behave the same way even if you call them something different, so
> what really is the point?
>From time to time we get newbies to Python assuming that len(list) is
O(N), because the lists they learned about in Comp Sci 101 (or Lisp) are
linked lists and traversing a linked list to count the items is O(N). Do
you believe that if Python lists were called "arrays", or "waskilators",
they would make the same mistake?
[Generalisation]
C programmers have a mental model for how "variables" behave. They have
no such mental model for how "objects bound to names" behave, and so they
are less likely to jump to conclusions about the behaviour of name-
bindings. So I think you are mostly wrong.
However, only mostly -- human beings are generalisers par excellence, or
rather, *over*-generalisers par excellence. Experienced coders are likely
to rapidly realise that name-binding is very similar to the C variable
model, and some percentage of them will over-generalise to assume that
name-binding is the same as the C model. But if they do, at least that
will be their fault for jumping to conclusions, not our fault for
misleading them.
--
Steven
More information about the Python-list
mailing list