WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-09-2009, 03:30 AM
jaclyn.bill jaclyn.bill is offline
Member
 
Join Date: Oct 2007
Posts: 42
Angry random.choice

I'm having some issues using random.choice which seem like a bug.

At the top of my script I have imported random and other random options are working in the script (e.g. random.uniform). However random choice keeps resulting in the error

'module' object has no attribute 'choice'

this is my code...

Code:
def createpath():

	Side_select = ([5.0,-5.0])
	XEXTENT = random.choice(Side_select) ### furthest extent of road
	XRANDOM = random.uniform(0.0,1.5) ### 
	ZCOORD = linspace(0.0, METERS,POINTS) #### z coords 0 - meters
	XCOORD = cos(ZCOORD/18.0)*XEXTENT*sin(ZCOORD/10.0)*XRANDOM
The strange issue is that when I start a fresh vizard file with just bottom five lines random.choice works.

Anyone have any ideas why this might be? I really need this to work within the context of my whole script.
Reply With Quote
  #2  
Old 09-09-2009, 12:19 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I would need to see your entire script to know what the problem is. It sounds like you are assigning another object to the name random. Please post the entire script. Also, try adding the following code before the line where accessing random.choice fails:
Code:
print random
Reply With Quote
  #3  
Old 09-11-2009, 03:07 AM
jaclyn.bill jaclyn.bill is offline
Member
 
Join Date: Oct 2007
Posts: 42
Hi,

There was no other object assigned to random. I have actually got it to work this morning by typing

Code:
import random
before every call of the random command. I'm not sure why this works, but it does! Thank you.

J
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT -7. The time now is 01:47 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC