I'm extending a former colleague's code (Python3) and find personally those repeated self.__local_object.x=some_result
annoying and hindering readabilit. I.e. instead of
self.__local_node.sign("computing partition for joining node %f<?<%f"%(
self.__local_node.partition_id,next_neighbour.partition_id))
partition_id = 0
if(next_neighbour != self.__local_node):
partition_id = PartitionID.gen_btw(self.__local_node.partition_id, next_neighbour.partition_id)
I'd rather use
ln=self.__local_node
ln.sign("computing partition for joining node %f<?<%f"%(
ln.partition_id,next_neighbour.partition_id))
partition_id = 0
if(next_neighbour != ln):
partition_id = PartitionID.gen_btw(ln.partition_id, next_neighbour.partition_id)
However, I'm not yet seasoned with Python development and I may be missing a golden guideline that will make further maintenance a nightmare if I introduce such (hopefully) local aliases for referenced objects.
PS: no, self.__local_node
's value is not altered any place in that code.
If you really don't change the value, only assingn or access its attributes, this should be perfectly ok.