Re:I'm Switching to Python and Actually Liking It
by deepsun on Wednesday July 16, 2025 @07:00PM
(#44587746)
Hey, you forgot useless comments for each method:
get_field1(self) -> int:
"""
Gets Field1.
@rtype: int
@return: the field1
"""
self._field1
And use double underscores for private fields, because, you know, encapsulation.Seriously though, in Java you don't need get*() either. Typically you either:
1. use `record` types (since Java14, 2020), or
2. use Lombok that auto-generates them [1], or
3. use Kotlin `data class`, or
4. just raw field access. I don't buy the encapsulation thing if my code is not a library for wide internet to use.
The reason why large Python codebases are particularly scary isn't necessarily the size itself. It's that for a codebase to even get that large in the first place it's very likely to have been around so long that the probability of it having had at least one major contributor who likes to do cute tricks like this is close to 1. And I'd take overly verbose like the Java example above over that kind of thing any day.