On 12 October 2012 03:22, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote:
> On Wed, 10 Oct 2012 23:44:42 -0700, suzaku wrote: > > > I think if a programmer has used the built-in `random` module before, he > > would expect a function with "sample" in its name to return a population > > sequence. > > I have used the random module for about fifteen years, and I still write > random.sample when I need to use random.choice. > > In statistics, probability, and plain English, a sample can be a single > item: that's why we can say "a sample" or "two samples". Because I have no soul, I'm going to have to correct you here. We can write "a multitude" or "several multitudes", but that doesn't mean a multitude can contain but one item. It's singular because we have *one collection*, not *one item*. That said, we can still have a sample *of one*. And *samples * of one. *teehee* > > If a function is to return scalar value instead of sequence, I would > > expect it to be named "choice". > > And I wouldn't. But what do I care? I'm never going to use the code > you're talking about, so call it "sasquatch" if you like, it's no skin > off my nose. >
-- http://mail.python.org/mailman/listinfo/python-list