I was wondering why many functions – especially in numpy – utilize tuples as function parameters?
e.g.:
a = numpy.ones( (10, 5) )
What could possibly be the use for that? Why not simply have something such as the following, since clearly the first parameters will always denote the size of the array?
a = numpy.ones(10, 5)
Is it because there might be additional parameters, such as dtype? even if so,
a = numpy.ones(10, 5, dtype=numpy.int)
seems much cleaner to me, than using the convoluted tuple convention.
Thanks for your replies
Because you want to be able to do:
and
other_array.shapeis a tuple. There are a few functions that are not consistent with this and work as you’ve described, e.g.numpy.random.rand()