4 ms·
Yes, you'd have to use just p. The convention in Lisp is it's just p unless the function name is multiple words anyway in which case the words are separated by
by cup-of-tea 9y ago
Yes, you'd have to use just p. The convention in Lisp is it's just p unless the function name is multiple words anyway in which case the words are separated by hyphens and the suffix is -p.
I suppose it is more Pythonic to name predicates like "is_full" or something rather than "fullp". But whatever it is I've found I can't stand not using some kind of naming convention for predicates.
- brudgers 9y agoI think the problem is more that Python doesn't really have the idea of predicates as an abstraction. It's not that it doesn't have predicates, it's just that they are not called that and not seen as thing in their own right and not something that programmers are encouraged to write.
- cup-of-tea 9y agoYeah, that's true. Maybe I'm being narrow minded and not "Pythonic" enough, but I always end up writing predicates. I can see that non-trivial predicate functions could be changed to non-trivial functions that return something which can later be compared to get the boolean. But what about having a list of of predicates and wanting to test them all at once. all(p(x) for p in predicates) seems perfect for this...