#use seperate namespace for the "math" module print('List of objects names in _main_ namespace:') print(dir()) import math print('List of objects names in _main_ namespace:') print('after "import math" has executed:') print(dir()) print('The value of pi is', math.pi) print('The tangent of 1 is', math.tan(1)) del(math) #use seperate aliased namespace for the "math" module print('List of objects names in _main_ namespace:') print(dir()) import math as fun print('List of objects names in _main_ namespace:') print('after "import math as fun " has executed:') print(dir()) print('The value of pi is', fun.pi) print('The tangent of 1 is', fun.tan(1)) del(fun) #import selectively into _main_ namespace print('List of objects names in _main_ namespace:') print(dir()) import math import pi, tan print('List of objects names in _main_ namespace:') print('after "from math import pi, tan" has executed:') print(dir()) print('The value of pi is', pi) print('The tangent of 1 is', tan(1)) del(pi)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question