Why is lambda allowed as a key in a dict?
rt8396 at gmail.com
Wed Mar 11 21:51:47 CET 2009
On Mar 11, 3:40 pm, Craig Allen <callen... at gmail.com> wrote:
> On Mar 10, 1:39 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> > Craig Allen <callen... at gmail.com> writes:
> > > it raises an interesting question about why doesn't it. I can think
> > > of practical answers to that, obviously, but in principle, if a
> > > function compiles to exactly the same byte code, you obviously do not
> > > need two copies of it, and like strings shouldn't an identical
> > > function have the same id?
> > Identical strings don't necessarily have the same id:
> > >>> a = "a"*1000
> > >>> b = "a"*1000
> > >>> id(a),id(b)
> > (137143648, 137144680)
> > >>> a==b
> > True
> interesting, I thought they were supposed to.
Are you joking? two objects == two ids. if not i would dump Python
Do you think Vector(0,0,0) and Vector(0,0,0) would have the same id?
More information about the Python-list