A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/097646.html below:

Namespace question

Namespace questionPark997 park997 at aol.comnotospam
Tue Apr 3 09:54:02 EDT 2001
Hi,

I am a little confused on what import does in a module's
namespace (Python 2.0). I have a modeule that includes the following code
(greatly pared down):

# SpongeRestoreObsR.py


import SpongeLS
import Statistics
import SpongeSetupObs
import random
from Numeric import *
from RandomArray import *


if __name__ == '__main__':
	
	
	fintime = 301

	for tim in range(fintime):	
		
			H = scen.noOfHours
		
			import random
		
			salhours = random.choice(H)  # Picks from list

			popvec=matrixmultiply(Dmat,popvec)

The "matrixmultiply" method from NumPy can be used with
no additional import statement, but the random.choice() method
will throw an AttributeError exception without another "import
random" statement. Why doesn't the first "import random" put it into the module
namespace? 

Thanks,

Wendell Cropper


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4