Message262982
> One to make it return a single number if amount == 1 and the other to check that the amount > 1.
Suggestion: if you want to go that way, return a single number if `amount` is not provided (so make the default value for `amount` None rather than 1). If `amount=1` is explicitly given, a list containing one item should be returned.
I also think there's no reason to raise an exception when `amount = 0`: just return an empty list.
For comparison, here's NumPy's "uniform" generator, which generates a scalar if the "size" parameter is not given, and an array if "size" is given, even if it's 1.
>>> np.random.uniform()
0.4964992470265117
>>> np.random.uniform(size=1)
array([ 0.64817717])
>>> np.random.uniform(size=0)
array([], dtype=float64) |
|
Date |
User |
Action |
Args |
2016-04-07 07:43:46 | mark.dickinson | set | recipients:
+ mark.dickinson, tim.peters, rhettinger, pitrou, aisaac, westley.martinez, serhiy.storchaka, NeilGirdhar, madison.may, dkorchem, Christian.Kleineidam, xksteven |
2016-04-07 07:43:46 | mark.dickinson | set | messageid: <1460015026.03.0.697693220372.issue18844@psf.upfronthosting.co.za> |
2016-04-07 07:43:46 | mark.dickinson | link | issue18844 messages |
2016-04-07 07:43:45 | mark.dickinson | create | |
|