lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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.

None in t # gives True

Jim Pryor