type of simple object
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Wed Feb 2 02:27:02 EST 2005
ajikoe at gmail.com a écrit :
> Thank you guys.
>
> My function should multiply every element of a list, for example
> "something"
> and "something" can be an integer or another list.
> If it deals with integer than it is ok, but
> If it deals with list than it become false for example list*2 =
> listlist, and what I really want is to mutlitply its member.
> That's why I need to know the type of my data in "something".
As stated by another comment, I would do something like :
def multiply(object, factor):
try:
return [ multiply(i,factor) for i in object ]
except TypeError:
return object*factor
This function will, recursively multiply a nested list of numbers by
"factor" ...
>
> By the way I am new in python, I heard that it has a MatLab
> capabilities, How good is that? Since It would be very nice when we can
> do what MatLab do in python.....
I think you are referring to the Numeric or the numarray modules. They
offer matric computations close to chat Matlab offers. "numarray" is the
newer version of "Numeric", but in case of small matrix, it performs
slower (for various reasons). Then, you can find lots of information on
the net concerning these two modules.
>
>
> Sincerely Yours,
> pujo
>
Pierre
More information about the Python-list
mailing list