Is this an inconsistency?

apardon at trout.vub.ac.be apardon at trout.vub.ac.be
Mon Mar 26 07:18:39 EST 2001


I'm a newbie what Python is concerned so my question may be
based on misconceptions. Also I'm still using 1.5.2

To get some experience with the language and for further
use in some toy-project I am currently working on a
Vector and Matrix class in Python.

A Matrix has just one attribute which is a list of
lists. The sublists each standing for a  row. Now
I had read in the tutorial that an easy way to
change to lists into a list of pairs was:

  map(None , list1 , list2)

And since you can turn a tuple into a list with
the function list, my way of transposing a matrix
was implemented as:

  map(list , apply(map , [None] + self.Value))


The trouble is that doesn't work if I have
a single row matrix. The trouble seems to
be that although

  map(None , list1 , list2 , list3 , ... )

turns a number of lists into a list of tuples.


  map(None , list)

Doesn't turn into a list of singletons but
just returns the list.

This seems a bit odd to me because if you
use apply with a single parameter function
the second argument has to be either a singleton
or a list with one element.


My question now: Is this behaviour changed in
the following versions? If not, wouldn't it be
more consistent if it was?

-- 
Antoon Pardon



More information about the Python-list mailing list