Does Python have equivalent to MATLAB "varargin", "varargout", "nargin", "nargout"?

2007-02-18 Thread openopt
Thank you in advance for your response.
Dmitrey

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does Python have equivalent to MATLAB "varargin", "varargout", "nargin", "nargout"?

2007-02-19 Thread openopt
Ok, thx
But can I somehow determing how many outputs does caller func require?
for example:
MATLAB:
function [objFunVal firstDerive secondDerive] = simpleObjFun(x)
objFunVal = x^3;
if nargout>1
firstDerive = 3*x^2;
end
if nargout>2
secondDerive = 6*x;
end

So if caller wants only
[objFunVal firstDerive] = simpleObjFun(15)
than 2nd derivatives don't must to be calculated with wasting cputime.
Is something like that in Python?

-- 
http://mail.python.org/mailman/listinfo/python-list


(beginners question) howto set self.field4.subfield8='asdf'?

2007-02-19 Thread openopt
I have
class A:
def __init__(self, objFun, x0):
#(I want to have self.primal.f = objFun)
#both
self.primal.f = objFun
#and
self.primal = None
self.primal.f = objFun

yields error
what should I do?
Thx

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (beginners question) howto set self.field4.subfield8='asdf'?

2007-02-19 Thread openopt
Thx
but is there any simpleir way, if using not class, but just struct (or
something like that, MATLAB equivalent for that one)?
I'm thinking of rewriting some optimization solvers (non-smooth,
constrained, with (sub)gradients or patterns provided by user) to
Python and I don't know currently is it possible to easy convert
things like
prob = [];
prob.advanced.ralg.hs = 1 (so in this line all subfields are
generating automatically in MATLAB or Octave)
I have huge amount of such lines, and implementing separate class for
each one is unreal.
Thank you in advance, Dmitrey


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (beginners question) howto set self.field4.subfield8='asdf'?

2007-02-19 Thread openopt
Thx
but is there any simpleir way, if using not class, but just struct (or
something like that, MATLAB equivalent for that one)?
I'm thinking of rewriting some optimization solvers (non-smooth,
constrained, with (sub)gradients or patterns provided by user) to
Python and I don't know currently is it possible to easy convert
things like
prob = [];
prob.advanced.ralg.hs = 1 (so in this line all subfields are
generating automatically in MATLAB or Octave)
I have huge amount of such lines, and implementing separate class for
each one is unreal.
Thank you in advance, Dmitrey


-- 
http://mail.python.org/mailman/listinfo/python-list


is it possible to remove the ':' symbol in the end of lines starting with 'if', 'while' etc?

2007-02-22 Thread openopt
I don't know to which forum should I post the message
I hope someone related to the Python kernel development will read &
consider the idea
I'm (a former? meanwhile not sure) MATLAB user & it's very annoing
typing each time for example
while i:
 print i
 ...
instead of
while i
print i
...
of course if all is written in a single line ':' I guess should not be
omited

Thank you for you suggestions.
Sorry my bad English.

WBR, Dmitrey

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is it possible to remove the ':' symbol in the end of lines starting with 'if', 'while' etc?

2007-02-22 Thread openopt
> Think on the bright side:
>
> you have to type ":" at the beginning of loop and conditional blocks,
> but you don't have to type "end"  at the end... you are still saving
> two strokes...
> ;-))

No, there no profits:
instead of 'end' I must type , ':' and backspace in the end of
block - so 3 keypress are used, same as 'end'
Of course Python is much more better in syntax vs C/C++ but I would
prefere tcl-style or caml-style
x = fun arg1 arg2 ... argn
however, in tcl annoing things are 'set' and 'expr'
and in ocaml '<-' and 'let x = ... in' - too many keypress instead of
'='
but their func calls still is better then fun(arg1, arg2, ..., argn)
and help _something_  or which _something_ in MATLAB is much more
better then help(_something_) in Python
the only bad thing in MATLAB (+absence of x = fun arg1 arg2 ... argn
call) is indexing arrays by () instead of [] - holding shift key
dozens times per day is very unconvinient.
And in Python vs MATLAB is very unconvinient arrays creation.

I'm very afraid of proposition that I noticed at
http://wiki.python.org/moin/SummerOfCode
Base multidimensional array type for Python core
Student: KarolLangner
Mentor: Travis E. Oliphant
I don't know about anyone mentioned but I'm not sure this is a good
idea to hire ordinary student for such important thing.
And writing 'dimarray(...)' dozens times per day is much more bad than
x = matrix('...'), x = array([...]) or, of course, MATLAB-style x = [1
2 3]
I guess it should 10 times more think about the array and make it once
and forever - Python already has some array-related classes and all
with syntax much more bad than MATLAB. I guess there should be only 2
types: one for storing data in convinient way without reallocating
(something like C++ STL vector<>) and one for quick calculations
(something like C++ valarray).
WBR, Dmitrey.

-- 
http://mail.python.org/mailman/listinfo/python-list


JIT (just-in-tme accelerator) for Python - exists or no?

2007-02-22 Thread openopt
Or is any progress going on now?

The JIT in MATLAB or Java seems to be very effective.

-- 
http://mail.python.org/mailman/listinfo/python-list