On 2009-07-25 02:55, Diez B. Roggisch wrote:
Dr. Phillip M. Feldman schrieb:
Here's a simple-minded example:
def dumbfunc(xs):
for x in xs:
print x
This function works fine if xs is a list of floats, but not if it is
single
float. It can be made to work as follows:
def dumbfunc(xs):
if isinstance(xs,(int,float,complex)): xs= [xs]
for x in xs:
print x
Having to put such extra logic into practically every function is one
of the
annoying things about Python.
And where comes "len(xs)" into play here? What you want is iteration
over scalars.
He explained in another post that iteration is another feature along the same
lines that he would want for scalars.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
--
http://mail.python.org/mailman/listinfo/python-list