Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > random.random(), random not defined!?

Reply
Thread Tools

random.random(), random not defined!?

 
 
globalrev
Guest
Posts: n/a
 
      04-19-2008
do i need to import something to use random?
 
Reply With Quote
 
 
 
 
Eduardo Schettino
Guest
Posts: n/a
 
      04-19-2008
On Sun, Apr 20, 2008 at 12:58 AM, globalrev <(E-Mail Removed)> wrote:
> do i need to import something to use random?
> --


you need to import random

Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> random.random()

0.76018998919085967
 
Reply With Quote
 
 
 
 
John Machin
Guest
Posts: n/a
 
      04-19-2008
globalrev wrote:
> do i need to import something to use random?


No, you need to import random
 
Reply With Quote
 
Mensanator
Guest
Posts: n/a
 
      04-19-2008
On Apr 19, 3:36´┐Żpm, John Machin <(E-Mail Removed)> wrote:
> globalrev wrote:
> > do i need to import something to use random?

>
> No, you need to import random


But you could alsways import it as something.

>>> import random as something
>>> something.random()

0.45811606256668347
 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      04-20-2008
En Sat, 19 Apr 2008 16:28:37 -0300, globalrev <(E-Mail Removed)> escribiˇ:

> do i need to import something to use random?


Let me guess: you have a script named random.py? Perhaps the same one you're executing?
In that case when you write "import random", you're importing *your* script instead of the standard one.

--
Gabriel Genellina

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
Random "The IListSource does not contain any datasources" and more (Crashing a live site at random, twice a week or so) Lars-Erik Aabech ASP .Net 8 04-28-2005 07:52 AM
random is not random enough? JNY C++ 25 12-30-2004 11:42 AM
Random not really random... Maziar Aflatoun ASP .Net 4 08-05-2004 01:26 AM
Random NOt random? Darren Clark ASP .Net 3 06-24-2004 05:23 PM



Advertisments