html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/3770#issuecomment-587149607,https://api.github.com/repos/pydata/xarray/issues/3770,587149607,MDEyOklzc3VlQ29tbWVudDU4NzE0OTYwNw==,1217238,2020-02-17T20:36:37Z,2020-02-17T20:36:37Z,MEMBER,"I'd be OK with callable support in where() and other methods, as long as we have a clear policy about what methods should/will support it. On Mon, Feb 17, 2020 at 11:29 AM keewis wrote: > The docs > > state that the builtin bool returns True for all objects unless __bool__ > is defined or __len__ returns 0 (function objects don't define either so > they use the fallback). I'm not sure why, but I suspect it is the way it is > to make > > if obj: > ... > > equivalent to > > if obj is not None: > ... > > That said I really like the callable support of pandas (e.g. Series.where), > so maybe we should add that too? > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > , > or unsubscribe > > . > ","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,565626748 https://github.com/pydata/xarray/issues/3770#issuecomment-586653324,https://api.github.com/repos/pydata/xarray/issues/3770,586653324,MDEyOklzc3VlQ29tbWVudDU4NjY1MzMyNA==,1217238,2020-02-16T00:01:54Z,2020-02-16T00:01:54Z,MEMBER,"This is a NumPy thing, too: ```python In [6]: np.where(lambda: None, 1, 2) Out[6]: array(1) ``` I think the problem is that functions cast to `True` with bool. (I don't really understand why that is the case, but it does seem to be well-established behavior in Python)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,565626748