| 1 | initial version |
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()))
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.