|
|
|
|
|
by dr_zoidberg
2314 days ago
|
|
Ufff that's rough to read. Totally. The only one I agree with is the one that says: Aim to align statement parts that are conceptually similar. It allows the reader to quickly see how they’re different. E.g. in this code it’s immediately clear that the two parts call the same code with different parameter orders.
That'd turn something like this: class OneClass:
def __init__(self, a, b1, b2, c_long):
self.a = a
self.b1 = b1
self.b2 = b2
self.c_long = c_long
Into this: class OneClass:
def __init__(self, a, b1, b2, c_long):
self.a = a
self.b1 = b1
self.b2 = b2
self.c_long = c_long
(maybe not the greatest example, there are places where this helps much more)The others all are un-pythonic and make the code more unreadable. |
|
But it only makes the code unreadable if you don't make a tiny effort to adjust. If you do make the effort, there's some great payoff, like this code:
That's the inner part of the training loop. You can see at a glance: what steps are in the loop; what callbacks are in the loop, in what order; what step corresponds to each callback. And you can see the whole training loop at once, which is great for getting a clear picture of what's going on.