I am new to OOP in python and have mostly only used it for static scoped methods. My question is this: if I want to declare a class "myclass.py" for importing into another "other.py", and myclass has dependencies on other modules, where do I import those dependencies?
#myclass.py
import numpy as np
class myclass:
def mymethod():
return np.array([1,2,3,4])
or is this needed:
#myclass.py
class myclass:
import numpy as np
def mymethod():
return np.array([1,2,3,4])
and
#other.py
import myclass
instance = myclass()
array = instance.mymethod()
So question, where do I import numpy as np
?
inside myclass.py or other.py or both?