On Sun, May 25, 2014 at 12:48:40PM +0530, diliup gabadamudalige wrote: > 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.
Try this: scalelist = list(all_scales) scale = random.choice(scalelist) which hopefully should do what you want. -- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor