random behavior in random module? 
Author Message
 random behavior in random module?

Some straaaaaaaange stuff:

chronis % python
Python 1.4 (Oct 26 1996)  [GCC 2.7.2]
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam

Quote:
>>> import random

Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python1.4/random.py", line 18, in ?
    from whrandom import random, uniform, randint, choice # Also for
export!
  File "/usr/local/lib/python1.4/whrandom.py", line 94, in ?
    _inst = whrandom()
  File "/usr/local/lib/python1.4/whrandom.py", line 39, in __init__
    self.seed(x, y, z)
  File "/usr/local/lib/python1.4/whrandom.py", line 51, in seed
    import time
  File "time.py", line 2, in ?
    from time import time
ImportError: cannot import name time
Quote:
>>> import random
>>> dir(random)

['__builtins__', '__doc__', '__file__', '__name__']
Quote:
>>> reload(random)

Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python1.4/random.py", line 18, in ?
    from whrandom import random, uniform, randint, choice # Also for
export!
ImportError: cannot import name random

At other times which, randomly I cannot seem to replicate at the
moment, It works fine with all the functions in the random module and
the test works ok too.

All I have to say is that this is random.  Is there no way to predict
the behavior of the module 'random'?

Scott
----------------------------------------------------------------------
          (215) 772 0535 * http://www.*-*-*.com/ ~cotton
----------------------------------------------------------------------



Thu, 22 Apr 1999 03:00:00 GMT  
 random behavior in random module?

Allright, I fixed the problem.  It was (obviously) that I had a file
called time.py that was loaded instead of timemodule.so. by the module
random.

Well, it was amusing thinking that maybe Guido had implemented some
random behavior in the module random'..

Scott

--

----------------------------------------------------------------------
    Scott Cotton * 2617 South St. Apt 2 * Philadelphia PA 19104 *
----------------------------------------------------------------------
         ((((((((    ))))))))))  .          ((((((       )))))))))
.          (((((( ( ))))))))             .    ((((((    )))))))    
.      .      |    ||||||               .       (((((())))))))    
.       .     |    ||||||       .             .  |    |||||||
              |    ||||||                        | |  |||||||        
        .     |    ||||||                        |    |||||||
             (((((()))))))      .   0            |    |||||||      
           ((((((    )))))))       /|\  .       (((((( )))))))        
         (((((((      )))))))))    /|         (((((((   ))))))))      
----------------------------------------------------------------------
          (215) 772 0535 * http://www.sas.upenn.edu/~cotton
----------------------------------------------------------------------



Thu, 22 Apr 1999 03:00:00 GMT  
 random behavior in random module?

Quote:
> chronis % python
> Python 1.4 (Oct 26 1996)  [GCC 2.7.2]
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import random
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
>   File "/usr/local/lib/python1.4/random.py", line 18, in ?
>     from whrandom import random, uniform, randint, choice # Also for
> export!
>   File "/usr/local/lib/python1.4/whrandom.py", line 94, in ?
>     _inst = whrandom()
>   File "/usr/local/lib/python1.4/whrandom.py", line 39, in __init__
>     self.seed(x, y, z)
>   File "/usr/local/lib/python1.4/whrandom.py", line 51, in seed
>     import time
>   File "time.py", line 2, in ?
>     from time import time
> ImportError: cannot import name time

Seems like you have a file "time.py" that gets loaded instead of the
standard built-in time module.  This can happen if you are loading
timemodule.so from a shared library.  I suggest renaming your time.py
-- having a local module with the same name as a standard module is
never a good idea...

--Guido van Rossum (home page: http://www.python.org/~guido/)



Fri, 23 Apr 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. random rant on random files

2. A truly random $random??

3. ? generating random uniform and binomial random deviates for BIG integers

4. Unit tests and random.Random()

5. Random number not random?

6. Random Number Generator to produce SAME random number from 12:00am-11:59pm

7. Opening random line from file with random.shuffle()

8. Random Numbers Module rv Release 1.1

9. random module?

10. Random Module

11. Random Module

12. module random: delay in "seeding"

 

 
Powered by phpBB® Forum Software