I created a module that will be used in several python scripts. The structure is as follows:
Main file:
import numpy as np from mymodule import newfunction f = np.arange(100,200,1) a = np.zeros(np.shape(f)) c = newfunction(f)
mymodule.py:
def newfunction(f): import numpy as np b = np.zeros(np.shape(f)) return b if __name__ == "__main__": import numpy as np
Ignore the functionality of this program, but the problem is that when I run it, I get "NameError: the global name" zeros "is not defined."
What did I miss here?
mymodule.py does not see:
import numpy as np
(s). "import" Python #include ++, , . "np" , .
if __name__ == "__main__": import numpy as np
- mymodule.py script, , , .
:
OP , import numpy as np , .
Source: https://habr.com/ru/post/1731329/More articles:Installation and integration of DOJO tools - dojoto connect SQL Server 2005/2008 over the Internet - sql-serverIN SQL statement - sqlHow to echo a session name in a foreach loop in PHP? - phpiPhone OCUnit, anonymously released with code 139, what is it? - iphoneHow to get started with Zend Framework developemt - phpWCF service returns Dataser very slowly with basicHttpBinding - wcfProblem with "Include File Search Path" in Delphi 2010 - delphiПереключение VS2008 между логикой форматирования - formattingWhat is the best alternative gettimeofday () library in C ++? - c ++All Articles