Readable code is usually considered pythonic. While this may seem foreign if Python is a second language, once you understand how the logical, coalescing operators work it becomes quite readable; therefore, I would say this is indeed pythonic.
I've seen this used all over, and prefer to use it myself. The alternative is to nest two assignment operations inside of an if..else
. This has always seemed counter-intuitive to me, because you're assigning a value to the same variable, but you must use two assignment operators. This is neither minimalist or readable, and therefore not pythonic.
As a side note, I often find myself missing these operators when I use other languages. I typically explain this behavior with the analogy "like Python's or
operator".