Python complaints

skaller skaller at maxtal.com.au
Thu Dec 16 13:02:52 EST 1999


choffman at dvcorp.com wrote:
> 
> In article <38576B73.59C7BA85 at udel.edu>,
>   Charles Boncelet <boncelet at udel.edu> wrote:
> 
> >
> > I think all functions that operate on single things should be able to
> > operate on a list of things and return a list of things. (Are there
> > obvious reasons why this paradigm can't work?) Consider,
> 
> Ignoring the suggestion that 'len' itself be changed, if you truly mean
> the language should automatically loop over lists, then there is
> certainly an obvious reason why this can't work.

> On the other hand, if you are simply suggesting that all the functions
> in the standard modules that accept scalar arguments should have their
> bodies rewritten so they also accept lists, and do an implicit loop over
> the list, your idea is reasonable. It would be a lot of work, 

	It is almost no work at all:

	Given a function sin, we can make sin_list, which works over
any sequence, returning a list, by using map, by:

	def sin_list(arglist):
		return map(sin, arglist)

We could also do:

	def sin_args(*arglist):
		return map(sin, arglist)

which is slightly different.

Now, go figure how easy it is to make a list of functions

	[f1, g1, k1, ...]

and generate all the 'mapped' variants of them.

-- 
John Skaller, mailto:skaller at maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
voice: 61-2-9660-0850



More information about the Python-list mailing list