[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Propsoal: a lua dialect without nil
- From: Jim Pryor <lists+lua@...>
- Date: Tue, 15 Feb 2011 08:54:52 -0500
On Tue, Feb 15, 2011 at 01:40:56PM +0100, Kristofer Karlsson wrote:
> In Python, I can do:
> t = dict()
> None in t # gives False
> t["foo"] # error
> t.get("foo"] # gives None
> t["foo"] = None
> t["foo"] # now gives None
> None in t # still gives False
>
> This makes it confusing. Python seems to use None both as a real value and
> as indicator of absense - since "None in t" will never give true.
That's because your last test was done wrongly---you assigned None as a
value, but `None in t` checks whether None is key.
t={}
t[None]="foo"
None in t # gives True
--
Jim Pryor
profjim@jimpryor.net