News for hackers. Stuff that matters.
Re:Pythonic monotonic by mjburgess on Friday August 13, 2021 @08:41AM (#28168156)
The first case is clearer to me than the second, by quite away.

Iter, next? Opaque testing of [-1] values?

Adjusting a few identifier names, the first actually describes what's going on.

Eg., rename `Monotonic()` to `CurrentLtLast()`

Re:Pythonic monotonic by ghshephard on Friday August 13, 2021 @10:24AM (#28169235)
It's really hard to do anything in python without `iter` and `next` - understanding iterators and `iter` in particular is table stakes with python.
Re:Pythonic monotonic by nearmuse on Friday August 13, 2021 @09:21AM (#28168493)
The problem is simple enough to solve without function calls at all (except maybe a comparator function) and this is why I like the second solution better: it is closer in spirit to the level of abstraction of the problem.

I think OP missed the point here: the interviewer was probably testing the candidate's Python chops by offering an opportunity to show off their knowledge of language features and standard library on a simple problem. The result is contrived by using __call__ and itertools, but is better for the purposes of the interview.

Re:Pythonic monotonic by recursive on Friday August 13, 2021 @10:41AM (#28169484)
`iter` seems more approachable than `__call__` to me FWIW.
Re:Pythonic monotonic by fantod on Friday August 13, 2021 @10:12AM (#28169073)
What's wrong with iter and next?