Closed dmtucker closed 8 years ago
Actually, this surprisingly seems to work, but the syntax is misleading about what is happening:
lambda y: y.address and name in y.names(x)
It looks like y.names
is a function being invoked to produce a list that name
may be in, but the lambda is, in fact, being invoked with x
(in which case y
and the lambda are not necessary).
edit: This does not work. The implicit bool is what "hides" the error:
>>> [i for i in range(5) if not (lambda x: x + y(i))]
[]
>>> [i for i in range(5) if not (lambda x: x + y(i)) < 3]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
TypeError: unorderable types: function() < int()
https://github.com/jonhadfield/python-hosts/blob/devel/python_hosts/hosts.py#L253
Since this lambda is not invoked, this is essentially doing
bool(func)
which is always True.This would probably be better: