1

I am new to Azure Databricks, and have run into a situation. I have a dev_tools python script in workspace/Shared/dev_tools location. The dev_tools script contains the following code (This is an example and not the actual code).

def add (first_num, second_num):
    return first_num + second_num

def multiply (first_num, second_num):
    return first_num * second_num

if __name__ == "__main__":
    print(add(3,6))

Now I have another script let's say myScript in workspace/Users/ashish that wants to import the function multiply() from dev_tools. How do I access that in the second script? I have used %run but that just runs the dev_tools script (Including the code in if name == "main") Which should not happen. Is there any other way to accomplish the task.

The final goal is to make the code re-usable, The functions and classes in dev_tools will be used by many scripts in the Users dir.

Ashish soni
  • 89
  • 1
  • 10

0 Answers0