Empty Monty Empty Monty - 1 year ago 92
Python Question

Importing and using modules in python

New to python and trying to do a random number generator. However, I am having trouble importing the random module. I get a AttributeError when I try to use anything from the random module. Thanks for your help.

#!/usr/bin/python -tt

import random

def main():
x = random.randint(1,1000)
print x

if __name__ == '__main__':

Answer Source

You probably have a file named random.py (or pyc) in your current directory. You can find out where the random module you're using comes from by doing this:

import random
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download