Skip to content

Commit

Permalink
Use 'rpartition' to get 'module_name' and 'function_name'
Browse files Browse the repository at this point in the history
  • Loading branch information
ealerskans committed Dec 13, 2024
1 parent e907a6d commit bb9be13
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions mllam_data_prep/derived_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,7 @@ def _get_derived_variable_function(function_namespace):
calling_module = globals()["__name__"]

# Get module and function names
function_namespace_list = function_namespace.rsplit(".")
if len(function_namespace_list) > 1:
function_name = function_namespace_list[-1]
module_name = ".".join(elem for elem in function_namespace_list[:-1])
else:
module_name = ""
function_name = function_namespace_list[0]
module_name, _, function_name = function_namespace.rpartition(".")

# Check if the module_name is pointing to here (the calling module or empty "")
# If it does, then use globals() to get the function otherwise import the
Expand Down

0 comments on commit bb9be13

Please sign in to comment.