def func(x): original = x x = pre(x) # Apply pre-splitting function x = splitter(x) # Split the string on numbers x = py23_filter(None, x) # Remove empty strings. x = py23_map(post, x) # Apply post-splitting function x = _sep_inserter(x, sep) # Insert empty strings between numbers return after(x, original) # Apply final manipulation
def func(x, original_func=input_transform if orig_after_xfrm else _no_op): # Apply string input transformation function and return to x. # Original function is usually a no-op, but some algorithms require it # to also be the transformation function. x, original = input_transform(x), original_func(x) x = splitter(x) # Split string into components. x = py23_filter(None, x) # Remove empty strings. x = py23_map(component_transform, x) # Apply transform on components. x = _sep_inserter(x, sep) # Insert '' between numbers. return final_transform(x, original) # Apply the final transform.
def func(x): # Apply string input transformation function and return to x. # Original function is usually a no-op, but some algorithms require it # to also be the transformation function. x = normalize_input(x) x, original = input_transform(x), original_func(x) x = splitter(x) # Split string into components. x = py23_filter(None, x) # Remove empty strings. x = py23_map(component_transform, x) # Apply transform on components. x = sep_inserter(x, sep) # Insert '' between numbers. return final_transform(x, original) # Apply the final transform.