I need to random pick a pygame sprite from a sprite class. The random module does not allow this to be used on a group. Is the shortest way to raed in the attributes thatr I need into a list and then random pick that or is there a shorter way? Sample code is given below.
scalelist=[] for scale in all_scales: scalelist.append( [scale.name, scale.scaletype] ) scale = random.choice(scalelist) where all_scales is a sprite class with 45 objects. I append the 2 attributes of each sprite to a scalelist with the above function and then random pick an item from the scalelist. Is this the shortest way? Thank you to all in advance. -- Diliup Gabadamudalige http://www.diliupg.com http://soft.diliupg.com/ ********************************************************************************************** This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. **********************************************************************************************
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor