when "normal" parallel computations in CPython will be implemented at last?
hi all, are there any information about upcoming availability of parallel computations in CPython without modules like multiprocessing? I mean something like parallel "for" loops, or, at least, something without forking with copying huge amounts of RAM each time and possibility to involve unpiclable data (vfork would be ok, but AFAIK it doesn't work with CPython due to GIL). AFAIK in PyPy some progress have been done ( http://morepypy.blogspot.com/2012/06/stm-with-threads.html ) Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
new release 0.38 of OpenOpt, FuncDesigner, SpaceFuncs, DerApproximator
Hi all, I'm glad to inform you about new release 0.38 (2012-March-15): OpenOpt: interalg can handle discrete variables interalg can handle multiobjective problems (MOP) interalg can handle problems with parameters fixedVars/freeVars Many interalg improvements and some bugfixes Add another EIG solver: numpy.linalg.eig New LLSP solver pymls with box bounds handling FuncDesigner: Some improvements for sum() Add funcs tanh, arctanh, arcsinh, arccosh Can solve EIG built from derivatives of several functions, obtained by automatic differentiation by FuncDesigner SpaceFuncs: Add method point.symmetry(Point|Line|Plane) Add method LineSegment.middle Add method Point.rotate(Center, angle) DerApproximator: Minor changes See http://openopt.org for more details Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
can I overload operators like "=>", "->" or something like that?
hi all, can I somehow overload operators like "=>", "->" or something like that? (I'm searching for appropriate overload for logical implication "if a then b") Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
why () is () and [] is [] work in other way?
I have spent some time searching for a bug in my code, it was due to different work of "is" with () and []: >>> () is () True >>> [] is [] False (Python 2.7.2+ (default, Oct 4 2011, 20:03:08) [GCC 4.6.1] ) Is this what it should be or maybe yielding unified result is better? D. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] OpenOpt Suite release 0.34
Hi all, I'm glad to inform you about new quarterly release 0.34 of the OOSuite package software (OpenOpt, FuncDesigner, SpaceFuncs, DerApproximator) . Main changes: * Python 3 compatibility * Lots of improvements and speedup for interval calculations * Now interalg can obtain all solutions of nonlinear equation or systems of them in the involved box lb_i <= x_i <= ub_i (bounds can be very large), possibly constrained (e.g. sin(x) + cos(y+x) > 0.5). * Many other improvements and speedup for interalg. See http://forum.openopt.org/viewtopic.php?id=425 for more details. Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] OpenOpt Suite release 0.34
Hi all, I'm glad to inform you about new quarterly release 0.34 of the free (even for commercial purposes, license: BSD) cross-platform OOSuite package software (OpenOpt, FuncDesigner, SpaceFuncs, DerApproximator), Main changes: * Python 3 compatibility * Lots of improvements and speedup for interval calculations * Now interalg can obtain all solutions of nonlinear equation (example) or systems of them (example) in the involved box lb_i <= x_i <= ub_i (bounds can be very large), possibly constrained (e.g. sin(x) + cos(y+x) > 0.5). * Many other improvements and speedup for interalg. See http://forum.openopt.org/viewtopic.php?id=425 for more details. Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
blist question
hi all, I feel lack of native Python lists operations (e.g. taking N greatest elements with the involved key function and O(n) speed) and occasionally found blist http://pypi.python.org/pypi/blist/ Its entry says it is better than Python list. Did anyone ensure? Will it ever be merged into Python source code? D. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] OpenOpt Suite release 0.33
Hi all, I'm glad to inform you about new release 0.33 of our completely free (license: BSD) cross-platform software: OpenOpt: * cplex has been connected * New global solver interalg with guarantied precision, competitor to LGO, BARON, MATLAB's intsolver and Direct (also can work in inexact mode) * New solver amsg2p for unconstrained medium-scaled NLP and NSP FuncDesigner: * Essential speedup for automatic differentiation when vector- variables are involved, for both dense and sparse cases * Solving MINLP became available * Add uncertainty analysis * Add interval analysis * Now you can solve systems of equations with automatic determination is the system linear or nonlinear (subjected to given set of free or fixed variables) * FD Funcs min and max can work on lists of oofuns * Bugfix for sparse SLE (system of linear equations), that slowed down computation time and demanded more memory * New oofuns angle, cross * Using OpenOpt result(oovars) is available, also, start points with oovars() now can be assigned easier SpaceFuncs (2D, 3D, N-dimensional geometric package with abilities for parametrized calculations, solving systems of geometric equations and numerical optimization with automatic differentiation): * Some bugfixes DerApproximator: * Adjusted with some changes in FuncDesigner For more details visit our site http://openopt.org. Regards, Dmitrey. -- http://mail.python.org/mailman/listinfo/python-list
seems like a bug in isinstance()
hi all, suppose I've created a class Point in file .../openopt/kernel/Point.py Consider the code in file .../somewhere/file1.py from openopt.kernel.Point import Point p = Point() now let's pass p into a func from .../openopt/kernel/file2.py and check from Point import Point isinstance(p, Point) So, it returns False! p is , while Point is I have Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) D. -- http://mail.python.org/mailman/listinfo/python-list
Re: seems like a bug in isinstance()
On May 6, 12:57 pm, Chris Rebert wrote: > On Fri, May 6, 2011 at 2:24 AM, dmitrey wrote: > > hi all, > > > suppose I've created a class Point in file .../openopt/kernel/Point.py > > > Consider the code in file .../somewhere/file1.py > > from openopt.kernel.Point import Point > > p = Point() > > > now let's pass p into a func from .../openopt/kernel/file2.py and > > check > > from Point import Point > > isinstance(p, Point) > > > So, it returns False! > > > p is , while Point is > openopt.kernel.Point.Point at 0x2048e20> > > > [Subject: seems like a bug in isinstance()] > > This is due to a peculiarity of how (C)Python's import machinery > works; isinstance() is working just fine. > (And if you ever think you've found a bug in Python's built-ins, odds > are you haven't. Python has been around too long, someone ought to > have encountered it earlier, statistically speaking.) > > Note how the class is referred to as both Point.Point and > openopt.kernel.Point.Point. This is because you did `from Point import > ...` in file2.py, whereas in file1.py you did `from > openopt.kernel.Point import ...`. These 2 different ways of referring > to the same module are sufficient to "trick"/"outsmart" (C)Python and > cause it to import the same module twice as 2 separate instances (i.e. > it gets re-executed). Why the import machinery isn't smarter in this > situation, I don't recall. > > The output of this should be illuminating: > print(Point, type(p), type(p) is Point, id(Point), id(type(p))) > As this demonstrates, you're dealing with 2 separate definitions of > the same Point class. > > Solution: Avoid the implicitly-relative `from Point import ...` style > of import; always use the absolute `from openopt.kernel.Point import > ...` style instead. Subsequent imports will thus reference the > already-previously-imported instance of a module rather than importing > a copy of it from scratch again. > > Cheers, > Chris > --http://rebertia.com Thanks Cris, however, I had understood reason of the bug and mere informed Python developers of the bug to fix it. >>> print(Point, type(p), type(p) is Point, id(Point), id(type(p))) (, , False, 44211536, 8585344) The proposed solution of using `from openopt.kernel.Point import ... ' everywhere is already performed but is not nice for me. I have lots of places like that in my code; also, when I import something from openopt it performs recursive import of many files including that one where Point is defined, thus I have cycled imports (well, it somehow works, but is unstable and may lead to future bugs). Also, writing "from Point import Point" is much simpler than using each time the long string "from name1.name2.Point import Point". I think it's Python developers who have to fix the issue, not users. I have 5 years of intensive Python experience yet it took same time to me to locate the bug, because my algorithm got "False" from isinstance() and went absolutely different thread from "if isinstance(): ... else: ...". This bug could be encountered very seldom under rare circumstances and thus be quite difficult to be located, especially for Python newbies unawared of this one. Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
Python 3 dict question
hi all, suppose I have Python dict myDict and I know it's not empty. I have to get any (key, value) pair from the dict (no matter which one) and perform some operation. In Python 2 I used mere key, val = myDict.items()[0] but in Python 3 myDict.items() return iterator. Of course, I could use for key, val in myDict.items(): do_something break but maybe there is any better way? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3 dict question
On May 6, 10:51 pm, Chris Rebert wrote: > On Fri, May 6, 2011 at 12:40 PM, dmitrey wrote: > > hi all, > > suppose I have Python dict myDict and I know it's not empty. > > I have to get any (key, value) pair from the dict (no matter which > > one) and perform some operation. > > In Python 2 I used mere > > key, val = myDict.items()[0] > > but in Python 3 myDict.items() return iterator. > > Of course, I could use > > for key, val in myDict.items(): > > do_something > > break > > but maybe there is any better way? > > key, val = next(myDict.items()) > > Cheers, > Chris Unfortunately, it doesn't work, it turn out to be dict_items: >>> next({1:2}.items()) Traceback (most recent call last): File "", line 1, in TypeError: dict_items object is not an iterator >>> dir({1:2}.items()) ['__and__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__rand__', '__reduce__', '__reduce_ex__', '__repr__', '__ror__', '__rsub__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__xor__', 'isdisjoint'] -- http://mail.python.org/mailman/listinfo/python-list
Python3: imports don't see files from same directory?
hi all, I try to port my code to Python 3 and somehow files don't see files from same directory, so I have to add those directories explicitly, e.g. import sys sys.path += [...] Also, it leads to bugs like this one: http://groups.google.com/group/comp.lang.python/browse_thread/thread/961a90219a61e19d# any ideas what's the reason and how to fix it? I have tried to search google but got nothing yet. Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: seems like a bug in isinstance()
On May 7, 11:53 am, Gregory Ewing wrote: > Chris Rebert wrote: > > This is because you did `from Point import > > ...` in file2.py, whereas in file1.py you did `from > > openopt.kernel.Point import ...`. These 2 different ways of referring > > to the same module are sufficient to "trick"/"outsmart" (C)Python and > > cause it to import the same module twice > > That can't be the whole story, because those two ways of > referring to the module *should* have returned the same > module object, even though one is absolute and the other > relative. > > I suspect what's happened is that somehow sys.path contains > both the directory containing .../openopt *and* the directory > .../openopt/kernel, and the second import is picking up > Point.py a second time as though it were a top-level module. > > This could have happened by starting an interactive session > while cd'ed to .../openopt/kernel, or by launching a .py > file from there as a main script. > > The solution is to make sure that sys.path only contains the > top level directories of the package hierarchy, and doesn't > also contain any of their subdirectories. > > Always using absolute imports may be a good idea stylistically, > but in this case it will only mask the symptoms of whatever > is really wrong, and further problems could result from the > same cause. > > -- > Greg > I suspect what's happened is that somehow sys.path contains both the directory containing .../openopt *and* the directory .../openopt/kernel Yes, you are right. But I have to do it due to another issue I haven't solved yet: Python3 imports don't see files from same directory http://groups.google.com/group/comp.lang.python/browse_thread/thread/9470dbdacc138709# Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
[ANN} OpenOpt, FuncDesigner, DerApproximator, SpaceFuncs release 0.36 Options
Hi all, new release of our free scientific soft (OpenOpt, FuncDesigner, DerApproximator, SpaceFuncs) v. 0.36 is out: OpenOpt: Now solver interalg can handle all types of constraints and integration problems Some minor improvements and code cleanup FuncDesigner: Interval analysis now can involve min, max and 1-d monotone splines R -> R of 1st and 3rd order Some bugfixes and improvements SpaceFuncs: Some minor changes DerApproximator: Some improvements for obtaining derivatives in points from R^n where left or right derivative for a variable is absent, especially for stencil > 1 See http://openopt.org for more details. Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] New free multifactor analysis tool for experiment planning
Hi all, you may be interested in new free multifactor analysis tool for experiment planning (in physics, chemistry, biology etc). It is based on numerical optimization solver BOBYQA, released in 2009 by Michael J.D. Powell, and has easy and convenient GUI frontend, written in Python + tkinter. Maybe other (alternative) engines will be available in future. See its webpage for details: http://openopt.org/MultiFactorAnalysis Regards, Dmitrey. -- http://mail.python.org/mailman/listinfo/python-list
multiprocessing module question
hi all, suppose I have a func F, list [args1,args2,args3,...,argsN] and want to obtain r_i = F(args_i) in parallel mode. My difficulty is: if F returns not None, than I should break calculations, and I can't dig in multiprocessing module documentation how to do it. Order doesn't matter for me (I have to find 1st suitable, where result of F is not None) Could anyone scribe me an example? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Ann: OpenOpt and FuncDesigner 0.37
Hi all, I'm glad to inform you about new release 0.37 (2011-Dec-15) of our free software: OpenOpt (numerical optimization): IPOPT initialization time gap (time till first iteration) for FuncDesigner models has been decreased Some improvements and bugfixes for interalg, especially for "search all SNLE solutions" mode (Systems of Non Linear Equations) Eigenvalue problems (EIG) (in both OpenOpt and FuncDesigner) Equality constraints for GLP (global) solver de Some changes for goldenSection ftol stop criterion GUI func "manage" - now button "Enough" works in Python3, but "Run/ Pause" not yet (probably something with threading and it will be fixed in Python instead) FuncDesigner: Major sparse Automatic differentiation improvements for badly- vectorized or unvectorized problems with lots of constraints (except of box bounds); some problems now work many times or orders faster (of course not faster than vectorized problems with insufficient number of variable arrays). It is recommended to retest your large-scale problems with useSparse = 'auto' | True| False Two new methods for splines to check their quality: plot and residual Solving ODE dy/dt = f(t) with specifiable accuracy by interalg Speedup for solving 1-dimensional IP by interalg SpaceFuncs and DerApproximator: Some code cleanup You may trace OpenOpt development information in our recently created entries in Twitter and Facebook, see http://openopt.org for details. For more information visit http://openopt.org Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get function string name from i-th stack position?
On Dec 30, 8:35 pm, Tim Chase wrote: > On 12/30/11 11:51, dmitrey wrote: > > > how to get string name of a function that is n levels above > > the current Python interpreter position? > > Use the results of traceback.extract_stack() > > from traceback import extract_stack > def one(x): > print "one", x > stk = extract_stack() > for mod, lineno, fun_name, call_code_text in stk: > print "[%s:%i] in %s" % (mod, lineno, fun_name) > def two(x): > print "two", x > one(x) > def three(x): > print "three", x > two(x) > three("Hi") > > -tkc Thank you. And what should I do to get function by itself instead of its string name, e.g. I want to know does this function is my_func or any other? For example, I would like to check is this function Python sum(), or maybe numpy.sum(), or anything else? Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get function string name from i-th stack position?
On Dec 30, 11:48 pm, Ian Kelly wrote: > On Fri, Dec 30, 2011 at 11:43 AM, dmitrey wrote: > > Thank you. And what should I do to get function by itself instead of > > its string name, e.g. I want to know does this function is my_func or > > any other? For example, I would like to check is this function Python > > sum(), or maybe numpy.sum(), or anything else? > > The Python stack only includes Python code objects. Built-ins like > sum won't appear in it because they're basically C functions and don't > have associated code objects. If you really want to see them, you > could probably do something with ctypes to inspect the C stack, but I > don't recommend it. > > You can get the Python code objects from the stack by calling > inspect.stack(), which includes each frame object currently on the > stack as the first member of each tuple. E.g.: > > frames = map(operator.itemgetter(0), inspect.stack()) > > Each frame has an f_code attribute that stores the code object > associated with that frame. Getting the actual function from the code > object is tricky, for two reasons. One, not all code objects > represent functions. There are also code objects for modules, class > definitions, and probably other thing as well. Two, code objects > don't have associated functions. The relationship is the reverse: > functions have associated code objects. You would have to iterate > over each function that you're interested in, looking for one with a > func_code attribute that "is" the frame's f_code attribute. > > In any case, testing function identity is a rather large rabbit hole > that is best avoided. These are mathematically the same function: > > def plus1(value): > return value + 1 > > plus_one = lambda x: x + 1 > > But they are two distinct function objects, and there is no way > programmatically to determine that they are the same function except > by comparing the bytecode (which won't work generally because of the > halting problem). > > What is it that you're trying to do? Perhaps the helpful folks on the > list will be able to suggest a better solution if you can provide more > details. > > Cheers, > Ian Maybe it is somehow possible to compare function id with my candidates id, e.g. PythonSumID = id(sum) import numpy NumpySumID = id(numpy.sum) func = getting_function_from_Nth_stack_level_above if id(func) == PythonSumID: elif id(func) == NumpySumID: else: I need it due to the following reason: FuncDesigner users often use Python or numpy sum on FuncDesigner objects, while FuncDesigner.sum() is optimized for this case, works faster and doesn't lead to "Max recursion dept exceeded", that sometimes trigger for numpy or Python sum() when number of summarized elements is more than several hundreds. I would like to print warning "you'd better use FuncDesigner sum" if this case has been identified. Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
how to get id(function) for each function in stack?
hi all, how to get id(func) for each func in stack? (I mean memory address, to compare it with id(some known funcs)) Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get id(function) for each function in stack?
On Jan 6, 8:28 pm, Ian Kelly wrote: > On Fri, Jan 6, 2012 at 11:02 AM, dmitrey wrote: > > hi all, > > how to get id(func) for each func in stack? (I mean memory address, to > > compare it with id(some known funcs)) > > Thank you in advance, D. > > The answer hasn't changed since your last thread about this. The > stack contains code objects, not functions. You can get the code > objects using inspect.stack(), and compare them to the func_code > attributes of the functions you're interested in. > > Also, there's no need to use id() for this. Just use the "is" > operator to check identity. > > for frame_tuple in inspect.stack(): > frame = frame_tuple[0] > if frame.f_code is some_function.func_code: > print("Found it!") > > Cheers, > Ian Python build-in function sum() has no attribute func_code, what should I do in the case? D. -- http://mail.python.org/mailman/listinfo/python-list
PEP: add __sum__ method
hi all, could you consider adding __sum__ method, e.g. Python sum(a) checks does a have attribute __sum__ and if it has, then a.__sum__() is invoked instead of Python sum(a). (for my soft FuncDesigner it would be very essential, I guess for many other soft as well, e.g. for PuLP, who has to use lpSum, because ordinary Python sum slows it very much, as well as my funcs, and for large-scale problems max recursion depth is exeeded). Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
howto obtain directory where current (running) py-file is placed?
Hi all, I guess this question was asked many times before, but I don't know keywords for web search. Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: howto obtain directory where current (running) py-file is placed?
On Jun 7, 10:18 am, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > On Jun 7, 8:39 am, dmitrey <[EMAIL PROTECTED]> wrote: Thank you. And what is the simplest way (without split/join, if exist) to obtain name of directory parent to directory my_directory_name? Thx, D. > > > Hi all, > > I guess this question was asked many times before, but I don't know > > keywords for web search. > > > Thank you in advance, D. > > import os > > d1 = os.path.dirname(__file__) > d2 = os.path.dirname(os.__file__) > > print d1 > print d2 -- http://mail.python.org/mailman/listinfo/python-list
easiest way to count memory eaten by call to Python func?
hi all, which way is the simplest for now to obtain the memory amount eaten by call to Python 'myfunc' function? Thx, D -- http://mail.python.org/mailman/listinfo/python-list
howto run a function w/o text output?
hi all, I have a y = some_func(args) statement, and the some_func() produces lots of text output. Can I somehow to suppress the one? Thx in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
howto resend args and kwargs to other func?
I need something like this: def func1(*args, **kwargs): if some_cond: return func2(*args, **kwargs) else: return func3(some_other_args, **kwargs) Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: howto resend args and kwargs to other func?
On Jul 1, 12:00 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > You 'need something like this', so write something like that. > Did you intend to ask a question? I would gladly write the one, but the example doesn't work, and I don't know any easy way (moreover any way) to make it work correctly. D. -- http://mail.python.org/mailman/listinfo/python-list
Re: howto resend args and kwargs to other func?
Thanks all, I have solved the problem. D. -- http://mail.python.org/mailman/listinfo/python-list
howto check is object a func, lambda-func or something else?
hi all, howto check is object Arg1 - a func, lambda-func - something else? I tried callable(Arg1), but callable(lambda-func) returnes False Thx, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: howto check is object a func, lambda-func or something else?
Thank you, I have fixed the bug -- http://mail.python.org/mailman/listinfo/python-list
howto make Python list from numpy.array?
howto make Python list from numpy.array? Thx, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: howto make Python list from numpy.array?
Thanks all. I tried all the approaches but they don't work in my situation I have a variable x that can be x = 1 x = [1, 2, 3] x = numpy.array([1,2,3]) so all troubles are with 1st case >>> x=1 >>> list(x) Traceback (most recent call last): File "", line 1, in TypeError: iteration over non-sequence >>> list(array(1)) Traceback (most recent call last): File "", line 1, in ValueError: Rank-0 array has no length. >>> array(1).tolist() Traceback (most recent call last): File "", line 1, in ValueError: rank-0 arrays don't convert to lists. >>> Here I used Python 2.4.3, numpy 1.02 -- http://mail.python.org/mailman/listinfo/python-list
matplotlib: howto redraw figure automatically, without stop in show()/draw()?
Hi all, here is a question already mentioned below, and I'm also interested in that one very much. unfortunatly, I can't write anything to matplotlib mailing lists because I constantly get server internal error (500) Does anyone knows the answer? (howto redraw figure automatically (for example update from time to time in cycle), without stop in show()/draw()?) Thx in advance, D. redcic <[EMAIL PROTECTED]> wrote: > I've already got this package. I just wanted to try something new. > However, since you talk about it, I've got a question regarding this > package. The execution of the code stops after the line: > pylab.show() > which is off course the last line of my code. My problem is that I > have to close the figure window in order to launch my program another > time. I'd like to be able to launch my program many times with > different parameters without having to close the figure windows before > each launch. > Just so you know, I'm using TkAgg backend. > Any hint ? -- http://mail.python.org/mailman/listinfo/python-list
matplotlib: howto set title of whole window?
hi all, does anyone know howto set title of whole window? (I mean not just area above plot but string in the same line where buttons 'close', 'iconify', 'fullscreen' are situated) Thx, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: matplotlib: howto set title of whole window?
No, it's just another one title it produces a figure with name "Figure 1" but I should somehow replace the string. It is possible in MATLAB via set(figureHandler, 'Name', 'my_string_here') D. On May 12, 2:52 am, [EMAIL PROTECTED] wrote: > On May 11, 3:44 pm, dmitrey <[EMAIL PROTECTED]> wrote: > > > hi all, > > does anyone know howto set title of whole window? (I mean not just > > area above plot but string in the same line where buttons 'close', > > 'iconify', 'fullscreen' are situated) > > Use coordinates to set a title for the current figure. > E.g., > > from pylab import * > from matplotlib.font_manager import FontProperties > > figtitle = 'This is my title above all subplots' > > t = gcf().text(0.5, > 0.95, figtitle, > horizontalalignment='center', > fontproperties=FontProperties(size=16)) > > subplot(121) > subplot(122) > show() > > -- > Hope this helps, > Steven -- http://mail.python.org/mailman/listinfo/python-list
howto get function from module, known by string names?
hi all, can anyone explain howto get function from module, known by string names? I.e. something like def myfunc(module_string1, func_string2, *args): eval('from ' + module_string1 + 'import ' + func_string2') return func_string2(*args) or, if it's impossible, suppose I have some modules module1 module2 module3 ... etc each module has it own funcs 'alfa', 'beta' and class module1, module2,... with same string name as module name. can I somehow pass module as function param and then import function 'alfa' from (for example) module8? and/or import class moduleN from moduleN? something like def myfunc(moduleK, *args): return moduleK.moduleK(*args) or return moduleK.alfa(*args) Thx, D -- http://mail.python.org/mailman/listinfo/python-list
Re: howto get function from module, known by string names?
And howto check does module 'asdf' exist (is available for import) or no? (without try/cache of course) Thx, D. Carsten Haese wrote: > On 15 May 2007 04:29:56 -0700, dmitrey wrote > > hi all, > > can anyone explain howto get function from module, known by string > > names? > > I.e. something like > > > > def myfunc(module_string1, func_string2, *args): > > eval('from ' + module_string1 + 'import ' + func_string2') > > return func_string2(*args) > > To find a module by its name in a string, use __import__. To find an object's > attribute by its name in a string, use getattr. > > Together, that becomes something like this: > > >>> def myfunc(module_string1, func_string2, *args): > ...func = getattr(__import__(module_string1), func_string2) > ...return func(*args) > ... > >>> myfunc("math", "sin", 0) > 0.0 > >>> myfunc("operator", "add", 2, 3) > 5 > > Hope this helps, > > -- > Carsten Haese > http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: howto get function from module, known by string names?
And howto check does module 'asdf' exist (is available for import) or no? (without try/cache of course) Thx, D. Carsten Haese wrote: > On 15 May 2007 04:29:56 -0700, dmitrey wrote > > hi all, > > can anyone explain howto get function from module, known by string > > names? > > I.e. something like > > > > def myfunc(module_string1, func_string2, *args): > > eval('from ' + module_string1 + 'import ' + func_string2') > > return func_string2(*args) > > To find a module by its name in a string, use __import__. To find an object's > attribute by its name in a string, use getattr. > > Together, that becomes something like this: > > >>> def myfunc(module_string1, func_string2, *args): > ...func = getattr(__import__(module_string1), func_string2) > ...return func(*args) > ... > >>> myfunc("math", "sin", 0) > 0.0 > >>> myfunc("operator", "add", 2, 3) > 5 > > Hope this helps, > > -- > Carsten Haese > http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: howto get function from module, known by string names?
And howto check does module 'asdf' exist (is available for import) or no? (without try/cache of course) Thx, D. Carsten Haese wrote: > On 15 May 2007 04:29:56 -0700, dmitrey wrote > > hi all, > > can anyone explain howto get function from module, known by string > > names? > > I.e. something like > > > > def myfunc(module_string1, func_string2, *args): > > eval('from ' + module_string1 + 'import ' + func_string2') > > return func_string2(*args) > > To find a module by its name in a string, use __import__. To find an object's > attribute by its name in a string, use getattr. > > Together, that becomes something like this: > > >>> def myfunc(module_string1, func_string2, *args): > ...func = getattr(__import__(module_string1), func_string2) > ...return func(*args) > ... > >>> myfunc("math", "sin", 0) > 0.0 > >>> myfunc("operator", "add", 2, 3) > 5 > > Hope this helps, > > -- > Carsten Haese > http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
howto check does module 'asdf' exist? (is available for import)
howto check does module 'asdf' exist (is available for import) or no? (without try/cache of course) Thx in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: howto get function from module, known by string names?
Sorry, some problems with internet connection yield these messages -- http://mail.python.org/mailman/listinfo/python-list
howto compile recursively all *.py files to *.pyc (from a directory my_dir)?
howto compile recursively all *.py files to *.pyc (from a directory my_dir)? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
howto reload Python module?
my Python module was changed in HDD (hardware disk drive), moreover, changed its location (but still present in sys.path). how can I reload a func "myfunc" from the module? (or howto reload whole module)? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
(beginners) howto ascribe _all_ fields of parent class to child class?
Hi all, I'm rewriting some code from other language to Python; can anyone explain me which way is the simpliest: I have class C1(): def __init__(self): self.a = 5 class C2(C1): def __init__(self): self.b = 8 c = C2() print c.b#prints 8 print c.a#prints error, because field a is absent so how can I wrote the code that I'll got all class C1 fields (not only funcs) Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
Python equivalents to MATLAB str2func, func2str, ischar, isfunc?
I can't find these via web serch thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
Re: Python equivalents to MATLAB str2func, func2str, ischar, isfunc?
Thank you (however in MATLAB ischar is the same as isstr) but what if I don't know the name of module? I.e. I have def myfunc(param): ... #where param can be both funcName or a function, and I want to obtain both name and func, something like if isinstance(param, basestring): func, funcName = , param else: func, funcName = param, param.__name__ what should I type instead of ? D. On Mar 14, 7:06 pm, Alexander Schmolck <[EMAIL PROTECTED]> wrote: > "dmitrey" <[EMAIL PROTECTED]> writes: > > I can't find these via web serch > > > thank you in advance, > > Dmitrey > > str2func: getattr(some_module, 'f') > func2str: f.__name__ > ischar: isinstance(x, basestring) and len(x) == 1 > isfunc: callable(x) # is most likely to be what you want > > 'as -- http://mail.python.org/mailman/listinfo/python-list
what are Python equivalent to MATLAB persistent or C++ static?
Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
right-format of integer output as text
hi all, I need printing the following: 1 2 3 ... 9 10 ... 99 100 ... 999 1000 1001 ... how can I implement this one in the simpliest way? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
right-format of integer output as text
hi all, I need printing the following: 1 2 3 ... 9 10 ... 99 100 ... 999 1000 1001 ... how can I implement this one in the simpliest way? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: right-format of integer output as text
There are some errors occured in displaing previous message, I meant all right borders are the same, + some number of spaces before integer numbers, according to the number of digits D. -- http://mail.python.org/mailman/listinfo/python-list
Re: right-format of integer output as text
Thank you Marc, it is exactly the same I asked for. D. -- http://mail.python.org/mailman/listinfo/python-list
looking for a fastest parallel approach for quick executing of lots small routines
hi all, I'm looking for a way to execute a number (from 2 to thouzands, usually small) of python functions as quikly as it's possible. There seems to be lots of solutions, for example mentioned at http://www.cimec.org.ar/python/ , but first of all it would be very nice if the module is included into the scipy module or Python core, for to minimize additional software dependences. So what is the best choise? And if noone is included in Python standard distribution - why it is so and is anything intended in future Python versions: 2.6 or later? Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
Re: looking for a fastest parallel approach for quick executing of lots small routines
I forgot to add: first of all I need sinchronious parallel calculations, not asinchronious D. -- http://mail.python.org/mailman/listinfo/python-list
why brackets & commas in func calls can't be ommited? (maybe it could be PEP?)
Hi all, I looked to the PEPs & didn't find a proposition to remove brackets & commas for to make Python func call syntax caml- or tcl- like: instead of result = myfun(param1, myfun2(param5, param8), param3) just make possible using result = myfun param1 (myfun2 param5 param8) param3 it would reduce length of code lines and make them more readable, + no needs to write annoing charecters. Maybe it will require more work than I suppose, for example handling of things like result = myfun(param1, myfun2(param5, param8), param3=15, param4=200) to result = myfun param1 (myfun2 param5 param8) param3=15 param4=200 #so it needs some more efforts to decode by compiler but anyway I think it worth. + it will not yield incompabilities with previous Python versions. WBR, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: why brackets & commas in func calls can't be ommited? (maybe it could be PEP?)
I think it should result result = func1(func2, arg) if you want result = func1(func2(arg)) you should use result = func1 (func2 arg) if ... = word1 word2 word3 ... then only word "word1" should be call to func "word1" with parameters word2, word3 etc > If you have > result = func1 func2 arg > is it > result = func1(func2, arg) > or > result = func1(func2(arg)) > > Miki <[EMAIL PROTECTED]>http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: why brackets & commas in func calls can't be ommited? (maybe it could be PEP?)
>foo bar baz >foo(bar,baz) 1st still is shorter by 1 char; considering majority of people use space after comma & number of parameters can be big it yileds foo bar baz bar2 bar3 bar4 vs foo(bar, baz, bar2, bar3, bar4) > result = func1 for this case should using result = func1() should remain + remaining function defenitions def myfun(param1, param2,...,paramk, *args, **kwargs) > How would you write "a = b(c())"? a = b c() >So what should "a b c d" be? >(a, b, c, d) >a(b, c, d) >a(b, (c, d)) >a(b(c, d)) >a(b(c(d))) I mentioned above that it should be 2nd case >I don't know how caml resolves these ambiguities, or even if caml resolves them Yes, he does it perfectly, hence Python could have same abilities. But I don't insist anything, I only proposed. Since majority disagreed with the proposition, it don't worth further discussion. WBR, D. P.S. Steven, many people aren't able speak English as good as you, so do I. I hope majority of readers will forgive me for wasting their costly attantion & time. -- http://mail.python.org/mailman/listinfo/python-list
Re: PyPy 1.0: JIT compilers for free and more
Hi! Suppose I have a py-written module. Is it possible somehow run PyPy on the whole module? I didn't find it in documentation. And if yes (or if just run in every module func) what will be after computer restart? Should I restart PyPy on the module once again? And are there any chances/intends for PyPy to be included into Python core? Thx, D. On Mar 28, 12:48 am, Carl Friedrich Bolz <[EMAIL PROTECTED]> wrote: > ==PyPy1.0: JIT compilers for free and > more > == > > Welcome to thePyPy1.0 release - a milestone integrating the results > of four years of research, engineering, management and sprinting > efforts, concluding the 28 months phase of EU co-funding! > > Although still not mature enough for general use,PyPy1.0 materializes > for the first time the full extent of our original vision: > > - A flexible Python interpreter, written in "RPython": > >- Mostly unaware of threading, memory and lower-level target platform > aspects. >- Showcasing advanced interpreter features and prototypes. >- Passing core CPython regression tests, translatable to C, LLVM and > .NET. > > - An advanced framework to translate such interpreters and programs: > >- That performs whole type-inference on RPython programs. >- Can weave in threading, memory and target platform aspects. >- Has low level (C, LLVM) and high level (CLI, Java, JavaScript) > backends. > > - A **Just-In-Time Compiler generator** able to **automatically** >enhance the low level versions of our Python interpreter, leading to >run-time machine code that runs algorithmic examples at speeds typical >of JITs! > > Previous releases, particularly the 0.99.0 release from February, > already highlighted features of our Python implementation and the > abilities of our translation approach but the **new JIT generator** > clearly marks a major research result and gives weight to our vision > that one can generate efficient interpreter implementations, starting > from a description in a high level language. > > We have prepared several entry points to help you get started: > > * The main entry point for JIT documentation and status: > >http://codespeak.net/pypy/dist/pypy/doc/jit.html > > * The main documentation and getting-startedPyPyentry point: > >http://codespeak.net/pypy/dist/pypy/doc/index.html > > * Our online "play1" demos showcasing various Python interpreters, >features (and a new way to program AJAX applications): > >http://play1.codespeak.net/ > > * Our detailed and in-depth Reports about various aspects of the >project: > >http://codespeak.net/pypy/dist/pypy/doc/index-report.html > > In the next few months we are going to discuss the goals and form of > the next stage of development - now more than ever depending on your > feedback and contributions - and we hope you appreciatePyPy1.0 as an > interesting basis for greater things to come, as much as we do > ourselves! > > have fun, > > thePyPyrelease team, > Samuele Pedroni, Armin Rigo, Holger Krekel, Michael Hudson, > Carl Friedrich Bolz, Antonio Cuni, Anders Chrigstroem, Guido Wesdorp > Maciej Fijalkowski, Alexandre Fayolle > > and many others: > http://codespeak.net/pypy/dist/pypy/doc/contributor.html > > What isPyPy? > > > Technically,PyPyis both a Python interpreter implementation and an > advanced compiler, or more precisely a framework for implementing dynamic > languages and generating virtual machines for them. > > The framework allows for alternative frontends and for alternative > backends, currently C, LLVM and .NET. For our main target "C", we can > can "mix in" different garbage collectors and threading models, > including micro-threads aka "Stackless". The inherent complexity that > arises from this ambitious approach is mostly kept away from the Python > interpreter implementation, our main frontend. > > PyPyis now also a Just-In-Time compiler generator. The translation > framework contains the now-integrated JIT generation technology. This > depends only on a few hints added to the interpreter source and should > be able to cope with the changes to the interpreter and be generally > applicable to other interpreters written using the framework. > > Socially,PyPyis a collaborative effort of many individuals working > together in a distributed and sprint-driven way since 2003. PyPywould > not have gotten as far as it has without the coding, feedback and > general support from numerous people. > > Formally, many of the current developers were involved in executing an > EU contract with the goal of exploring and researching new approaches > to language and compiler development and software engineering. This > contract's duration is about to end this month (March 2007) and we are > working and preparing the according final review which is scheduled > for May 2007. > > For the future,
problem with Python class creating
Hi all, I have the code like this one: from myMisc import ooIter class MyClass: def __init__(self): pass iterfcn = lambda *args: ooIter(self) # i.e pass the class instance to other func named ooIter field2 = val2 field3 = val3 # etc So it yields "global name 'self' is not defined", that is true. How could I handle the situation? Currently I do (and it works, but give me some troubles - I should call MyClass.__init__ for each children class, and there are lots of those ones) class MyClass: def __init__(self): iterfcn = lambda *args: ooIter(self) # i.e pass the class instance to other func named ooIter field2 = val2 field3 = val3 # etc I suspect it has better solution, is it? Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
Re: problem with Python class creating
Thanks all for these detailed explanations. On Oct 18, 10:48 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > dmitrey a écrit : > Not unless these classes define their own initializers. But that's > another problem > > > and there are lots of > > those ones) > > > class MyClass: > > def __init__(self): > > iterfcn = lambda *args: ooIter(self) > > The real problem is that you create one anonymous function *per instance*. No, it's not a problem - it's desired behaviour. Regards, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
Python strings question (vertical stack)
Hi all, I have some strings, let it be string1, string2, string3. So how could String= """ string1 string2 string3 """ be obtained? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python strings question (vertical stack)
Thanks all, I have solved the problem: a=""" %s %s %s """ % ('asdf', 'asdf2', 'asdf3') print a D. -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOpt install
Use python setup.py install Regards, D On Dec 16, 2:27 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > What do I need to do? I have numpy, scipy (Fedora F8) > > cdopenopt/ > [EMAIL PROTECTED] python setup.py build > running build > running config_cc > unifing config_cc, config, build_clib, build_ext, build commands --compiler > options > running config_fc > unifing config_fc, config, build_clib, build_ext, build commands --fcompiler > options > running build_py > creating build > creating build/lib > creating build/lib/scikits > copying scikits/__init__.py -> build/lib/scikits > creating build/lib/scikits/openopt > copying scikits/openopt/__init__.py -> build/lib/scikits/openopt > copying scikits/openopt/info.py -> build/lib/scikits/openopt > copying scikits/openopt/oo.py -> build/lib/scikits/openopt > Traceback (most recent call last): > File "setup.py", line 101, in > import scikits > ImportError: No module named scikits -- http://mail.python.org/mailman/listinfo/python-list
Re: OpenOpt install
When earlier OpenOpt versions had been installed there were no compiled pyc-files (in destination directory). I called to mailing list but no obvious receipt had been achieved. Matthieu had done some changes but it yielded other mistakes (no some py-files detected or kind of), so I had removed those changes and write my own, for to have OO py-files being compiled when installed, because next time when they will be run user may not have root permissions, so he will recompile source files each time OO starts. On Dec 17, 10:27 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > dmitrey wrote: > > Use > > python setup.py install > > People should be able to run the distutils commands independently. > > What are you trying to achieve with this block of code that follows the > setup() > call? > > new_name = 'tmp55' > os.rename('scikits', new_name) > newPath = [] > for directory in sys.path: > if not 'scikits' in directory: newPath.append(directory)# something > wrong with list.remove() > sys.path = newPath > import scikits > reload(scikits) > Path = scikits.__path__[0] > NewPath = os.path.join(Path, 'openopt') > rmtree(NewPath, True) # True means ignore errors > copytree(os.path.join(os.path.curdir, new_name, 'openopt'), NewPath) > NewPath = Path > compileall.compile_dir(NewPath) > > os.rename(new_name, 'scikits') > > This just looks like a really bad idea. > > -- > 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
Re: OpenOpt install
thank you, I'll try to fix the issue when I'll have more time, I'm short of the one for now because of some other urgent work. D. On Dec 18, 10:53 am, Robert Kern <[EMAIL PROTECTED]> wrote: > dmitrey wrote: > > When earlier OpenOpt versions had been installed there were no > > compiled pyc-files (in destination directory). I called to mailing > > list but no obvious receipt had been achieved. Matthieu had done some > > changes but it yielded other mistakes (no some py-files detected or > > kind of), so I had removed those changes and write my own, for to have > > OO py-files being compiled when installed, because next time when they > > will be run user may not have root permissions, so he will recompile > > source files each time OO starts. > > Well, the problem there is that you have put code into subdirectories that > aren't packages. Then you manually add the directories to sys.path when you > import scikits.openopt.oo . This is a bad thing to do for several reasons; one > reason is that you don't get the correct .pyc files. > > You need to make the directory structure match the package structure. For > example, you currently have the module scikits.openopt.LP in > scikits/openopt/Kernel/LP/LP.py . You have two options: > > * you can make the directory structure match the package structure by moving > the files to the correct location: > > $ mv scikits/openopt/Kernel/LP/LP.py scikits/openopt/LP.py > > * you can make the package structure match the directory structure by adding > __init__.py files to the subdirectories and changing the imports to match: > > $ touch scikits/openopt/Kernel/__init__.py > $ touch scikits/openopt/Kernel/LP/__init__.py > $ vim scikits/openopt/oo.py > # 1. Delete the sys.path munging. > # 2. Change "from LP import LP as CLP" to "from Kernel.LP import LP as > CLP" > > -- > 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
Re: ANN: eric4 4.1.0 released
Hi all, I prefer the Eric Python IDE to all other, however, unfortunately, Eric4.x (as well as the latest snapshot mentioned in the ann) fails to debug any py-file (while Eric3.9.5 from Kubuntu software channel works ok): The debugged program raised the exception unhandled TypeError "not all arguments converted during string formatting" File: /usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugBase.py, Line: 515 Could you fix the issue? Kubuntu 7.10, AMD Athlon, Python 2.5. Regards, D. On Feb 3, 5:45 pm, Detlev Offenbach <[EMAIL PROTECTED]> wrote: > Hi, > > eric4 4.1.0 was just released. This is a major feature release. Compared > to 4.0.4 it contains these features next to bug fixes. > > - Added a plugin system for easy extensibility > - Converted the following interface to plugins available separately > -- PyLint checker > -- CxFreeze packager > -- CharTables tool > -- CVS version control system > -- BRM refactoring > - Added new project types > -- Eric4 Plugin > -- Django > -- TurboGears > -- wxPython > - Added source code exporters for > -- HTML > -- PDF > -- RTF > -- Latex > - Added subversion repository and log browsers > - Included API files for > -- eric4 > -- Django > -- TurboGears > -- wxPython > -- Zope 2 > -- Zope 3 > - Many enhancements to the functionality already there > > What is eric4? > -- > eric4 is a Python (and Ruby) IDE with all batteries included. Please > seehttp://www.die-offenbachs.de/ericfor details and screenshots. > > Regards, > Detlev > -- > Detlev Offenbach > [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: future multi-threading for-loops
On Feb 5, 5:22 am, [EMAIL PROTECTED] wrote: > Some iterables and control loops can be multithreaded. Worries that > it takes a syntax change. > > for X in A: > def f( x ): > normal suite( x ) > start_new_thread( target= f, args= ( X, ) ) > > Perhaps a control-flow wrapper, or method on iterable. > > @parallel > for X in A: > normal suite( X ) > > for X in parallel( A ): > normal suite( X ) > I would propose "for X IN A" for parallel and remain "for X in A" for sequential. BTW for fortress lang I had proposed "for X <- A" and "for X <= A" for sequential/parallel instead of current "for X <- seq(A)", "for X <- A", mb they will implement my way instead. -- http://mail.python.org/mailman/listinfo/python-list
Re: future multi-threading for-loops
On Feb 5, 6:11 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Multi-threaded control flow is a worthwhile priority. > > It is? That's totally new to me. Given the fact that threads don't scale > I highly doubt your claim, too. I would propose "for X IN A" for parallel and remain "for X in A" for sequential. BTW for fortress lang I had proposed "for X <- A" and "for X <= A" for sequential/parallel instead of current "for X <- seq(A)", "for X <- A", mb they will implement my way instead. -- http://mail.python.org/mailman/listinfo/python-list
IronPython vs CPython: faster in 1.6 times?
Hi all, the url http://torquedev.blogspot.com/2008/02/changes-in-air.html (blog of a game developers) says IronPython is faster than CPython in 1.6 times. Is it really true? If yes, what are IronPython drawbacks vs CPython? And is it possible to use IronPython in Linux? D. -- http://mail.python.org/mailman/listinfo/python-list
ANN: OpenOpt 0.17 (free numerical optimization framework)
Greetings, We're pleased to announce: OpenOpt 0.17 (release), free (license: BSD) optimization framework for Python language programmers, is available for download. Brief introduction to numerical optimization problems and related software: http://scipy.org/scipy/scikits/wiki/OOIntroduction Changes since previous release (December 15): * new classes: GLP (global problem), MMP (mini-max problem) * several new solvers written: goldenSection, nsmm * some more solvers connected: scipy_slsqp, bvls, galileo * possibility to change default solver parameters * user-defined callback functions * changes in auto derivatives check * "noise" parameter for noisy functions * some changes to NLP/NSP solver ralg * some changes in graphical output: initial estimations xlim, ylim * scaling * some bugfixes Newsline: http://openopt.blogspot.com/ Homepage: http://scipy.org/scipy/scikits/wiki/OpenOpt -- http://mail.python.org/mailman/listinfo/python-list
memory allocation for Python list
hi all, I have a python list of unknown length, that sequentially grows up via adding single elements. Each element has same size in memory (numpy.array of shape 1 x N, N is known from the very beginning). As I have mentioned, I don't know final length of the list, but usually I know a good approximation, for example 400. So, how can I optimize a code for the sake of calculations speedup? Currently I just use myList = [] for i in some_range: ... myList.append(element) ... Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
OpenOpt 0.21 (free optimization framework)
Hi all, OpenOpt 0.21, free optimization framework (license: BSD) with some own solvers and connections to tens of 3rd party ones, has been released. All details here: http://openopt.blogspot.com/2008/12/openopt-release-021.html Regards, OpenOpt developers. -- http://mail.python.org/mailman/listinfo/python-list
Tkinter question: howto redirect text output (stdout) to Text widget?
hi all, could anyone post an example how to redirect text output (stdout) to Text widget? Thank you in advance, Dmitrey. -- http://mail.python.org/mailman/listinfo/python-list
[numerical optimization] Poll "what do you miss in OpenOpt framework"
Hi all, I created a poll "what do you miss in OpenOpt framework", could you take participation? http://www.doodle.com/participation.html?pollId=a78g5mk9sf7dnrbe Let me remember for those ones who is not familiar with OpenOpt - it's a free Python-written numerical optimization framework: http://openopt.org I intend to take you opinions into account till next OpenOpt release 0.23 (2009-03-15) Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
multiprocessing module - isn't it a bug?
# THIS WORKS OK from multiprocessing import Pool N = 400 K = 800 processes = 2 def costlyFunction2(z): r = 0 for k in xrange(1, K+2): r += z ** (1 / k**1.5) return r class ABC: def __init__(self): pass def testParallel(self): po = Pool(processes=processes) r = po.map(costlyFunction2, xrange(N), chunksize = N/ (10*processes)) A=ABC() A.testParallel() print 'done' # But when I define costlyFunction2 inside of class, it doesn't work: from multiprocessing import Pool N = 400 K = 800 processes = 2 class ABC: def __init__(self): pass def testParallel(self): po = Pool(processes=processes) def costlyFunction2(z): r = 0 for k in xrange(1, K+2): r += z ** (1 / k**1.5) return r r = po.map(costlyFunction2, xrange(N), chunksize = N/ (10*processes)) A=ABC() A.testParallel() print 'done' Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 522, in __bootstrap_inner self.run() File "/usr/lib/python2.6/threading.py", line 477, in run self.__target(*self.__args, **self.__kwargs) File "/usr/lib/python2.6/multiprocessing/pool.py", line 225, in _handle_tasks put(task) PicklingError: Can't pickle : attribute lookup __builtin__.function failed This doesn't work for costlyFunction2 = lambda x: 11 as well; and it doesn't work for imap, apply_async as well (same error). So, isn't it a bug, or it can be somehow fixed? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
ANN: OpenOpt 0.23 - free numerical optimization framework
Hi all, OpenOpt 0.23, a free numerical optimization framework (license: BSD) with some own solvers and connections to tens of 3rd party ones, has been released. Our new homepage: http://openopt.org Introduction to the framework: http://openopt.org/Foreword All release details are here: http://openopt.org/Changelog or http://forum.openopt.org/viewtopic.php?id=58 Special thanks to Stepan Hlushak for writing GLP (global) solver "de" ("differential evolution"). Regards, OpenOpt developers. -- http://mail.python.org/mailman/listinfo/python-list
howto use pylint from Eric IDE?
Hi all, I have Eric 4.1.1, pylint and Eric pylint plugin installed, but I cannot find how to use pylint from Eric IDE GUI. Does anyone know? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python for programming algorithms
Along with numpy & scipy there is some more Python scientific soft worse to be mentioned: http://scipy.org/Topical_Software http://pypi.python.org/pypi?:action=browse&show=all&c=385 On 18 Тра, 06:25, Henrique Dante de Almeida <[EMAIL PROTECTED]> wrote: > once I > looked for linear programming toolkits for python and IIRC, I only > could find a trivial wrapper for glpk (called pulp). You could be interested in OpenOpt, it has connections to LP solvers glpk, cvxopt's one and lp_solve (former & latter allows handling MILP as well) http://scipy.org/scipy/scikits/wiki/LP -- http://mail.python.org/mailman/listinfo/python-list
Re: howto use pylint from Eric IDE?
Since I have no project (and willing to create the one), just several py-files, the Project->Check button is disabled. Are there any other methods in v4.1.1 or more recent? Thx, D. On 18 Тра, 16:48, Detlev Offenbach <[EMAIL PROTECTED]> wrote: > dmitrey wrote: > > Hi all, > > > I have Eric 4.1.1, pylint and Eric pylint plugin installed, but I > > cannot find how to use pylint from Eric IDE GUI. > > Does anyone know? > > > Thank you in advance, D. > > Project->Check->Run PyLint > > Regards, > Detlev > -- > Detlev Offenbach > [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
howto split string with both comma and semicolon delimiters
hi all, howto split string with both comma and semicolon delimiters? i.e. (for example) get ['a','b','c'] from string "a,b;c" I have tried s.split(',;') but it don't work Thx, D. -- http://mail.python.org/mailman/listinfo/python-list
write Python dict (mb with unicode) to a file
hi all, what's the best way to write Python dictionary to a file? (and then read) There could be unicode field names and values encountered. Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
ANN: OpenOpt 0.18 (numerical optimization framework)
Greetings, We're pleased to announce: OpenOpt 0.18 (release), free (license: BSD) optimization framework (written in Python language) with connections to lots of solvers (some are C- or Fortran-written) is available for download. Changes since previous release 0.17 (March 15, 2008): * connection to glpk MILP solver (requires cvxopt v >= 1.0) * connection to NLP solver IPOPT (requires python-ipopt wrapper installation, that is currently available for Linux only, see openopt NLP webpage for more details) * major changes for NLP/NSP solver ralg * splitting non-linear constraints can benefit for some solvers * unified text output for NLP solvers * handling of maximization problems (via p.goal = 'max' or 'maximum') * some bugfixes, lots of code cleanup Newsline: http://openopt.blogspot.com/ Homepage: http://scipy.org/scipy/scikits/wiki/OpenOpt Regards, OpenOpt developers. -- http://mail.python.org/mailman/listinfo/python-list
howto check is function capable of obtaining **kwargs?
hi all, howto check is function capable of obtaining **kwargs? i.e. I have some funcs like def myfunc(a,b,c,...):... some like def myfunc(a,b,c,...,*args):... some like def myfunc(a,b,c,...,*args, **kwargs):... some like def myfunc(a,b,c,...,zz=zz0):... So I need to know is the given function capable of handling zz parameter, for example the call myfunc(a,b,c,...,zz=4,...) Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: Genetic programming: pygene, pygp, AST, or (gasp) Lisp?
also, you could look at the simple openopt example provided by GA "galileo" solver (connected to OO framework) http://projects.scipy.org/scipy/scikits/browser/trunk/openopt/scikits/openopt/examples/glp_1.py http://scipy.org/scipy/scikits/wiki/GLP Regards, D -- http://mail.python.org/mailman/listinfo/python-list
howto print binary number
hi all, could you inform how to print binary number? I.e. something like print '%b' % my_number it would be nice would it print exactly 8 binary digits (0-1, with possible start from 0) Thank you in advance, D -- http://mail.python.org/mailman/listinfo/python-list
simple question about Python list
hi all, suppose I have 2 lists list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5'] and list2 = [0, 2, 4] # integer elements howto (I mean most simple recipe, of course) form list3 that contains elements from list1 with indexes from list2, i.e. list3 = ['elem0', 'elem2', 'elem4']? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to kill Python interpreter from the command line?
in addition to killall and kill funcs mentioned above you could be interested in pkill see "man pkill" from terminal for more details pkill python or pkill pyt or pkill py -- http://mail.python.org/mailman/listinfo/python-list
Re: simple question about Python list
Ok, I use Python 2.5 but I try my code to remain Python 2.4 and (preferable) 2.3 compatible. Are there other solutions? D. On 9 Тра, 13:17, Paul Hankin <[EMAIL PROTECTED]> wrote: > On May 9, 11:04 am, dmitrey <[EMAIL PROTECTED]> wrote: > > > list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5'] > > and > > list2 = [0, 2, 4] # integer elements > > > howto (I mean most simple recipe, of course) form list3 that contains > > elements from list1 with indexes from list2, i.e. > > list3 = [list1[i] for i in list2] > > -- > Paul Hankin -- http://mail.python.org/mailman/listinfo/python-list
Re: simple question about Python list
Hmm... I thought this issue is available from Python2.5 only. I have no other interpreters in my recently installed KUBUNTU 8.04. Thanks all, D. On 9 Тра, 13:41, Duncan Booth <[EMAIL PROTECTED]> wrote: > dmitrey <[EMAIL PROTECTED]> wrote: > > On 9 ôÒÁ, 13:17, Paul Hankin <[EMAIL PROTECTED]> wrote: > >> On May 9, 11:04šam, dmitrey <[EMAIL PROTECTED]> wrote: > > >> > list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5'] > >> > and > >> > list2 = [0, 2, 4] # integer elements > > >> > howto (I mean most simple recipe, of course) form list3 that contains > >> > elements from list1 with indexes from list2, i.e. > > >> list3 = [list1[i] for i in list2] > > > Ok, I use Python 2.5 but I try my code to remain Python 2.4 and > > (preferable) 2.3 compatible. > > Are there other solutions? > > D. > > Did you try Paul's suggestion? > > Python 2.3.5 (#1, Oct 13 2005, 09:17:23) > [GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-52)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> > list1 = ['elem0', 'elem1', 'elem2', 'elem3', 'elem4', 'elem5'] > >>> list2 = [0, 2, 4] > >>> list3 = [list1[i] for i in list2] > >>> list3 > > ['elem0', 'elem2', 'elem4'] -- http://mail.python.org/mailman/listinfo/python-list
PYPI, some troubles
hi all, 1. when I commit a new release to PYPI, I can use stored data (by my browser: Name, package summary, keywords etc), but in the last line (classification) I had to chose all those lines from the very beginning, moreover, if I click at one of them without pressing "CTRL" all my choices drops & I have to type it from the very beginning (I use Mozilla Firefox 3.0 but I don't think it's the matter). 2. Another issue: I have attached my source code (openopt0.19.tar.bz2 file), now I can see it in "files for openopt 0.19" section (http:// pypi.python.org/pypi) but easy_install can't find the package: # easy_install openopt Searching for openopt Reading http://pypi.python.org/simple/openopt/ Couldn't find index page for 'openopt' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading http://pypi.python.org/simple/ Reading http://pypi.python.org/simple/OpenOpt/ Reading http://scipy.org/scipy/scikits/wiki/OpenOpt No local packages or download links found for openopt error: Could not find suitable distribution for Requirement.parse('openopt') Does anyone know what shoul I do? Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
how to do easy_install to source code, not egg?
Hi all, how to do easy_install to source code, not egg? (I don't mean "develop" option, it shouldn't call compiled egg-file). Thank you in advance, Dmitrey. -- http://mail.python.org/mailman/listinfo/python-list
How to kill threading.Thread instance?
hi all, Is there a better way to kill threading.Thread (running) instance than this one http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496960 (it's all I have found via google). BTW, it should be noticed that lots of threading module methods have no docstrings (in my Python 2.5), for example _Thread__bootstrap, _Thread__stop. Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to kill threading.Thread instance?
I wonder why something like myThread.exit() or myThread.quit() or threading.kill(myThread) can't be implemented? Is something like that present in Python 3000? Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
[Tkinter] how to keep a window above all other OS windows?
Hi all, how to keep a Tkinter window above all other OS windows (i.e. including those ones from other programs)? Thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list
Re: how to keep a window above all other OS windows?
On Sep 23, 11:21 pm, dmitrey <[EMAIL PROTECTED]> wrote: > Hi all, > how to keep a Tkinter window above all other OS windows (i.e. > including those ones from other programs)? > > Thank you in advance, > Dmitrey I have put [Tkinter] into topic of my message but somehow it has been removed. D. -- http://mail.python.org/mailman/listinfo/python-list
how to get a class instance name during creation?
hi all, I have a code z = MyClass(some_args) can I somehow get info in MyClass __init__ function that user uses "z" as name of the variable? I.e. to have __init__ function that creates field z.name with value "z". Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to get a class instance name during creation?
On Oct 3, 9:46 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > dmitrey a écrit : > > > hi all, > > I have a code > > z = MyClass(some_args) > > can I somehow get info in MyClass __init__ function that user uses "z" > > as name of the variable? > > > I.e. to have __init__ function that creates field z.name with value > > "z". > > This has been debated to hell and back. To make a long story short, here > are two common use cases: > > x = MyClass() > y = x > del x > > objects = [MyClass() for i in range(100)] > > If you can come with a meaningfull answer to "what's *the* name of any > of the MyClass instance(s)" in both cases, then please let us know... I had seen the examples during google search, still I hoped for an answer to my exact situation. I know for sure there will be no renaming and creating like the above objects = [MyClass() for i in range(100)]. as for the z = MyClass(some, args, 'z') I had it in my mind but I hoped to have something automatic, w/o the arg 'z'. Regards, D. -- http://mail.python.org/mailman/listinfo/python-list
__mul__ vs __rmul__ (and others) priority for different classes
hi all, I have created a class MyClass and defined methods like __add__, __mul__, __pow__, __radd__, __rmul__ etc. Also, they are defined to work with numbers, Python lists and numpy.arrays. Both Python lists and numpy arrays have their own methods __add__, __mul__, __pow__, __radd__, __rmul__ etc. If I involve myPythonList * myClassInstance it returns just result of my __rmul__; but when I invoke nuumpy_arr*myClassInstance it returns another numpy array with elements [nuumpy_arr[0]*myClassInstance, nuumpy_arr[1]*myClassInstance, ...]. Can I somehow prevent numpy array of using it __mul__ etc methods? (and use only my __rmul__, __radd__, etc instead)? Thank you in advance, D. -- http://mail.python.org/mailman/listinfo/python-list
[ANN] OpenOpt 0.27 (optimization), FuncDesigner 0.17 (auto differentiation)
Hi all, I'm glad to inform you about release of OpenOpt 0.27 (numerical optimization framework), FuncDesigner 0.17 (CAS with automatic differentiation, convenient modelling of linear/nonlinear functions, can use convenient modelling for some OpenOpt optimization problems and systems of linear/nonlinear equations, possibly sparse or overdetermined), DerApproximator 0.17 (finite-differences derivatives approximation, get or check user-supplied). These packages are written in Python language + NumPy; license BSD allows to use it in both free and closed-code soft See changelog for details: http://openopt.org/Changelog Regards, D. -- http://mail.python.org/mailman/listinfo/python-list