From: Darren D. <dd...@co...> - 2004-11-17 00:51:25
|
Hi Chris, >> Matlab also returns one object- the varargout cell array which is >> similar to Python's list or tuple. You write a function, and pack >> varargout with nargout results: [a,b]=matlabfun(). > > > > I haven't used Matlab for a while, and not a newer version than 5.*, > but IIRC, while the above notation looks, like you are returning a > cell array, you could not call that fun with a single return argument. > Perhaps that's changed, in which case you shouldn't use nargout in > Matlab either! Maybe my example wasn't clear. There are good reasons for using varargout and nargout in Matlab. If I write a function to fit a peak, I can return the position, height, FWHM and sumResiduals along with some information about how the peakfitting algorithm concluded. If a user calls [p,h,fwhm,sr] = peakfit(x,y), you use nargout to determine that the caller does not want the algorithm report. > > Anyway, my main point was that kludging a nargout implementation in > python was not a good idea. I'd much rather see matplotlib be > pythonesque than matlabesque. Perhaps my goals are different than > others, but I use Python, rather than Matlab, largely because I like > the language better. > I originally looked into Python because everyone who works with it loves it, and it is free. I felt that the switch could be quick and painless because of John and the other MPL developers efforts with the Matlab interface. I would probably have waited to switch until after graduating if I hadnt googled "Python AND Matlab" one fateful day. (Cornell recently sent me a survey asking whether I felt $230 was fair for a 12 month license!). The matlab interface is already matlabesque. I think *args and Matlab's varargin are equivalent. Let me write up some examples using nargout as it is intended to be used, and I'll submit them to the list in a new thread. This one has strayed a bit from the original topic. Darren |