<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_and_alter(self, function):
 """ Alters the currently stored value by applying a function on it on and gets the old value. :param function: (Function), A stateful serializable object which represents the Function defined on server side. This object must have a serializable Function counter part registered on server side with the actual ``org.hazelcast.core.IFunction`` implementation. :return: (long), the old value. """

        check_not_none(function, "function can't be None")
        return self._encode_invoke(atomic_long_get_and_alter_codec, function=self._to_data(function))