Ask Your Question

Revision history [back]

If you insist on a one-liner (which isn't necessarily easier to read than your original three liner in my opinion) and don't want to inject a new method or subclass Vector, you can always define your own top level normalize function and use function composition instead of chaining method calls:

def normalize(v): return v/v.norm()
some_other_computation(normalize(some_vector_computation()))