I have created a module: test.py
. Inside it looks like:
import matplotlib.pyplot as plt
N = 5
def test_img(data_loc):
#F = load images from data_loc
def plot_img(im):
# a bunch of other codes
plt.imshow(im)
for i in range(N):
plot_img(F(i))
(1) To use it somewhere as import test
or from test import test_img
, where do I import matplotlib.pyplot as plt
? Is it inside test.py
like it is now?
(2) Does it matter plot_img
is nested inside test_img
in this case, if it is only going to be used inside test_img
?
(3) Does it matter where do I declare constant N
(This is an example, I have a lot of constants)? What if it is used inside plot_img
, where do I declare it?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.