News for hackers. Stuff that matters.
Re:Lily: An interpreted language with a focus on expressiven... by cpeterso on Thursday July 19, 2018 @04:36PM (#17570024)
You can use dict's get() method to get back a None for missing keys instead of throwing a KeyError exception. That avoids the overhead of checking `if key in dict` or catching KeyError.
Re:Lily: An interpreted language with a focus on expressiven... by wool_gather on Thursday July 19, 2018 @05:02PM (#17570229)
Another option, it's very easy to wrap a dict in a defaultdict:

    class optionaldict(defaultdict):
	"""
	A defaultdict that disregards KeyErrors and returns None for missing keys.
	"""
	def __init__(self, *original, **kwargs):
	    super().__init__(lambda: None, *original, **kwargs)
Re:Lily: An interpreted language with a focus on expressiven... by Quelklef on Friday July 20, 2018 @12:53AM (#17572571)
This is almost always a bad idea, though; it doesn't distinguish between

    {k: None}[k]
and

    {}[k]
Re:Lily: An interpreted language with a focus on expressiven... by bvrmn on Friday July 20, 2018 @01:06AM (#17572623)
It's not a generic option, you are polluting memory with non-existing keys.