matplotlib.mlab.find() not quite like Matlab"s

Darren Dale wrote:

    >> >I guess there is no way in Python of emulating >Matlab"s
    >> detection of the number of output arguments. I just got a
    >> response from c.l.p. Somebody remembered seeing this at ASPN:
    >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/284742
    >> expecting() is the workhorse, equivalent to Matlab's nargout:

    > Very cool. but I'd caution against using it. I'd much
    > rather see matplotlib be pythonesque than an exact
    > duplicate of MATLAB. This is NOT pythonesque!

I tend to agree with the caution against using it. But it would be
useful in some contexts, like converting existing matlab m-files to
python/numeric/numarray, the desire for which has occurred in some
contexts. Last time the discussion came up, the lack of nargout was
raised as a problem for any converter code.

    > Precisely speaking, python functions ALWAYS return just one
    > object: A tuple. That tuple can contain any number of other
    > objects, and sequence unpacking means it can look like
    > you're returning multiple values, but you're not
    > really. i.e.

What do you mean that python functions always return a tuple? How
about functions that return an int, or a string, or whatever?

def func(): return 1
type(func())

<type 'int'>

Do you mean that python functions that return tuples always return
tuples <wink> ?

JDH

John Hunter wrote:

What do you mean that python functions always return a tuple? How
about functions that return an int, or a string, or whatever?

def func(): return 1
type(func())

<type 'int'>

Do you mean that python functions that return tuples always return
tuples <wink> ?

no, I was a bit wrong. Python functions always return one object, and when it appears that you are returning multiple objects, you are really returning a single tuple with multiple objects in it. Have I got it right this time?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...