math.choice attribute error

Rikard Bosnjakovic bos at hack.org
Tue Mar 27 01:13:34 EST 2001


iddwb wrote:

> from the ref man math.choice says it takes a sequence object and returns a
> random choice. perfect for my needs. the follow happens:
[...]
> what have I missed?

The method choice lives in the module random, which the math-module
imports (IIRC). Try to import random and run choice instead, it should
work.

   >>> import random
   >>> random.choice((1,42,4711))
   42


-- 
Rikard Bosnjakovic - http://a214.ryd.student.liu.se/cv/ - ICQ: 1158217

Anyone sending unwanted advertising e-mail to my address will be
charged $250 for network traffic and computing time. By extracting my
address from this message or its header, you agree to these terms.



More information about the Python-list mailing list