Is `wsample` a proper name for a function like this?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Oct 11 22:22:15 EDT 2012


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".


> 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.

:)


-- 
Steven



More information about the Python-list mailing list