|
|
|
|
|
by HaroldCindy
542 days ago
|
|
I wasn't aware that single-file Java without a top-level static class was possible now, that + JBang seems quite useful for small tasks. One nit: > Python programmers often use ad-hoc dictionaries (i.e. maps) to aggregate related information. In Java, we have records: In modern Python it's much more idiomatic to use a `typing.NamedTuple` subclass or `@dataclasses.dataclass` than a dictionary. The Python equivalent of the Java example: @dataclasses.dataclass
class Window:
id: int
desktop: int
x: int
y: int
width: int
height: int
title: str
@property
def xmax(self) -> int: return self.x + self.width
@property
def ymax(self) -> int: return self.y + self.height
w = Window(id=1, desktop=1, x=10, y=10, width=100, height=100, title="foo")
|
|