lambda

Just just at xs4all.nl
Mon Jan 17 10:29:17 EST 2005


In article <slrncunk89.36o.apardon at rcpc42.vub.ac.be>,
 Antoon Pardon <apardon at forel.vub.ac.be> wrote:

> >> I don't see a big difference between these principles
> >> and the hash key principle,
> >
> > Than you haven't looked hard enough.
> 
> All of these can get unexpected behaviour because of the
> assignment-doesn't-copy semantics. The same semantics
> that can cause problems if you work with mutable dictionary
> keys.

Again, the difference is:

  1. assigning mutable objects *can* cause unexpected behavior
     (however, it's a useful feature, everyone using Python
     for longer than a day or two knows this, and then it's
     *expected* behavior.

  2. mutating dict keys *does* *always* cause problems.
     (unless you use an identity hash/cmp)

It's nonsense to forbid 1) since it's a useful feature. It's useful to 
forbid ("discourage") 2) since mutating dict keys is seldom useful (and 
when it is, Python lets you support it in your own objects).

Just



More information about the Python-list mailing list