Skip to content

Instantly share code, notes, and snippets.

@Sulkar
Last active August 13, 2017 12:08
Show Gist options
  • Save Sulkar/862cba9dc71bdf03da05a0858a06062a to your computer and use it in GitHub Desktop.
Save Sulkar/862cba9dc71bdf03da05a0858a06062a to your computer and use it in GitHub Desktop.
[python] testing "import xxx" and "from xxx import xxx"
# import random module
import random
tempRandom = random.randint(0, 9)
print(tempRandom)
# lists all functions of the random module
print(dir(random))
# import only randint function of random module
from random import randint
tempRandom = randint(0, 9)
print(tempRandom)
@Sulkar
Copy link
Author

Sulkar commented Aug 13, 2017

explanation why from x import * not importing everything:
https://stackoverflow.com/questions/19883870/python-from-x-import-not-importing-everything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment