Random module missing?

Robert Kern robert.kern at gmail.com
Wed Sep 23 17:13:03 EDT 2009


On 2009年09月23日 16:00 PM, Brown, Rodrick wrote:
> I seen some documentation about random.random() but my version seems to be broken?
>> Python 2.3.4 (#1, Jul 16 2009, 07:03:37)
> [GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import random
>>>> dir(random)
> ['__builtins__', '__doc__', '__file__', '__name__']
>>>> random.random()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: 'module' object has no attribute 'rand
>> Please advise thanks.

Do you happen to have an empty file named random.py somewhere on your system? 
Like in your current directory? Try printing random.__file__ to see exactly what 
file that module is associated with.
-- 
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
 -- Umberto Eco


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /