Hi,
I need to perform leastSquaresFit of a model that is given by a
differential equation for which there seems to be no analytic
solution. So, I am trying to solve the ODE numerically (using
scipy.integrate.odeint) within the function I provide to
leastSquaresFit as a model:
def func(L, t, a,
On Dec 4, 10:39 am, Cong Ma [EMAIL PROTECTED] wrote:
Lawrence D'Oliveiro wrote:
for \
Entry \
in \
sorted \
(
f for f in os.listdir(PatchesDir) if PatchDatePat.search(f) !=
None
) \
:
Patch = (open,
On Nov 27, 6:42 pm, Viktor Kerkez [EMAIL PROTECTED] wrote:
Is this a bug?
It is not a bug: the dictionaries are different because they are
loaded from different modules.
import os
import test.data
test.data
module 'test.data' from 'test/data.pyc'
os.chdir('test')
import data
data
module
http://wiki.python.org/moin/NumericAndScientific/Libraries
Scroll down.
Yes, many of those seem to be deprecated, without destinations to
links, most are poorly or not documented at all. The few that are, I
still can't get running. Of those 254, I think I have tried at least
10 pages
doesnt sum first construct the list then sum it?
def com(lst):
return sum(x for x in lst)
You construct a generator over an existing list in your code.
Try sum([x for x in lst]) to see the effect of additional list
construction. And while you're at it, try the simple sum(lst).
Cheers,
-
Thanks to all respondents, Steve Holden
is right, I expected more than I should
have.
Others have explained why all your examples work as they should.
From your exmaples, it seems like you would like strip to
remove the leading and trailing characters from EVERY LINE in
your string. This can
Hi Alexandre,
On Oct 24, 2:09 pm, Alexandre Badez [EMAIL PROTECTED] wrote:
I'm just wondering, if I could write a in a better way this code
Please tell us, what it is you want to achieve. And give us some
context
for this function.
lMandatory = []
lOptional = []
for arg in cls.dArguments:
Dear list,
I looked through the list but could not find any solutions for my
current problem.
Within my program, I am importing a module via
__import__(module_name,globals(),locals())
and I want to pass comand line options to this module. I would prefer
not to save them
in a config module or a
Hi Alan,
One last point. While I remain interested in examples of how
late addition ofattributesto class instances is useful,
I must note that everyone who responded agreed that it
has been a source of bugs. This seems to argue against a
general ban on locking objects in some way, in some
hi,
Jay wrote:
I'm writing a python script that involves playing mp3 files. The first
approach I had was sending commands to unix command-line programs in
order to play them. I tired mpg123 and moosic, but there was a key
feature to my program's success that's missing. SEEK! I need to be
Thanks for your advices, Terry and Konrad,
using the linear fit as initial condition for the pawerlow fit works
pretty well for my data.
(I already had the two calculations but performed them vice versa ...
:-) Anyway, I had
the impression that the leastSquaresFit in Scientific Python is an
Dear all,
I am trying to fit a powerlaw to a small dataset using
Scientific.Functions.LeastSquares fit.
Unfortunately, the algorithm seems to diverge and throws an
OverflowException.
Here is how I try it:
from Scientific.Functions.LeastSquares import leastSquaresFit
data = [
... (2.5,
hi,
groves wrote:
Now let me tell you that i was able to create a simple listbox which
had 6 options which one can select, but Now what I want is that from
the available menu, if I select an option it should give me another
menu associated with that option. Its like digging up that option to
MTD wrote:
Hello,
I'm wondering if there's a quick way of resolving this problem.
In a program, I have a list of tuples of form (str,int), where int is a
count of how often str occurs
e.g. L = [ (X,1),(Y,2)] would mean X occurs once and Y occurs
twice
If I am given a string, I want to
Hi,
I need to create a temporary file and I need to retrieve the path of
that file.
os.tmpnam() would do the job quite well if it wasn't for the
RuntimeWarning
tmpnam is a potential security risk to your program. I would like to
switch
to os.tmpfile() which is supposed to be safer, but I do not
Im not a total noob but i don't know the command and the module to go
from python to the default shell.
there are several ways depending on what exactly you want to achieve:
sys.exit(return_value):
terminates the python process and gives controll back to the shell
Maric Michaud wrote:
Le Jeudi 08 Juin 2006 15:30, Harold Fellermann a écrit :
to os.tmpfile() which is supposed to be safer, but I do not know how to
get
the path information from the file object returned by tmpfile(). any
clues?
There is no path for tmpfile, once it's closed, the file
Chris Lambacher wrote:
You should be able to find exactly what you need in the tempfile module.
http://docs.python.org/lib/module-tempfile.html
thanks! tempfile.NamedTemporaryFile() is exaclty what I have been
looking
for. Using python for such a long time now, and still there are unknown
Fredrik Lundh wrote:
George Sakkis wrote:
It would be useful if list.sort() accepted two more optional
parameters
+1
useful for what? what's the use case ?
Actually, I was in need of such a construct only few weeks ago. The
task was to organize playlists
of an mp3 player. I wanted to
The main difference is that lists are mutables while tuples are not.
Tuples are fine if you only want to group some objects (e.g. as a
return value) and access their members as in
t = (1,2,3,4)
t[2]
3
Lists give you a lot more flexibility, because they are mutable: you
can change the order of
I usually go for the webbrowser package that allows me to launch the
systems webbrowser and opens my html help files. It is really simple:
import webbrowser
webbrowser.open(file:///path_to/help.html#topic)
and thats all there is to do.
- harold -
--
import sys
sys.stdout = file(output,w)
print here you go
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
I want to use the current need for a Levenberg-Marquardt least squares
fitting procedure
for my long term desire to dive into scientific libraries for python.
However, I am always
confused by the shear sheer variety of available packages and the fact
that some of them
(Numeric, Numarray)
Better go for the subprocess module. It is supposed to replace os.popen
and has a much nicer interface.
- harold -
--
http://mail.python.org/mailman/listinfo/python-list
Great!
sys.excepthook() is exactly what I was looking for. Thank you.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I am writing an application that initializes the global namespace, and
afterwards, leaves the user with the python prompt. Now, I want to
catch NameErrors in user input like e.g.
some_name
Traceback (most recent call last):
File stdin, line 1, in ?
NameError: name 'some_name' is not
Jerry,
if you want anyone to answer your question, please read this:
http://www.catb.org/~esr/faqs/smart-questions.html
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Still, I'm designing an application that I want to be extendable by
third-party developers. I'd like to have some sort of documentation
about what behavior is required by the components that can be added to
extend the application. I'd thought I might try documenting
for f in os.listdir(os.path.abspath(libdir)):
module_name = f.strip('.py')
import module_name
Obviously, this throws:
ImportError: No module named module_name
Is there some way to do this?
have a look at help(__import__) to import a module whose name is given
as a string.
-
Hi,
I have a list of variables, which I am iterating over. I need to set
the value of each variable. My code looks like:
varList = [ varOne, varTwo, varThree, varFour ]
for indivVar in varList:
indivVar = returnVarFromFunction()
However, none of the variables in the list are being
I have a list of variables, which I am iterating over. I need to set
the value of each variable. My code looks like:
varList = [ varOne, varTwo, varThree, varFour ]
for indivVar in varList:
indivVar = returnVarFromFunction()
However, none of the variables in the list are being set.
I would like to know how I could automatically fill a
(search) form on a web page and download the resulting
html page. More precisely I would like to make a
program that would automatically fill the Buscador
lista 40 (in spanish, sorry) form in the following
webpage:
On 07.07.2005, at 15:25, Giles Brown wrote:
Nah. You're missing my point. I only want the command window not to
be closed if there is an *exception*. Picky I know, but there you go.
well, then register raw_input as exit function:
import atexit
atexit.register(raw_input)
works fine in
On 07.07.2005, at 15:43, harold fellermann wrote:
On 07.07.2005, at 15:25, Giles Brown wrote:
Nah. You're missing my point. I only want the command window not to
be closed if there is an *exception*. Picky I know, but there you go.
well, then register raw_input as exit function
I'm trying to implement __iter__ on an abstract base class while I
don't
know whether subclasses support that or not.
Hope that makes sense, if not, this code should be clearer:
class Base:
def __getattr__(self, name):
if name == __iter__ and hasattr(self, Iterator):
On 06.07.2005, at 18:58, Jeremy wrote:
Hello all,
I am trying to inherit the file object and don't know how to do it. I
need to open a file and perform operations on it in the class I am
writing. I know the simple syntax is:
class MyClass(file):
...
but I don't know how to
I don't know if I should be inheriting file or just using a file
object.
How would I determine which one would be more appropriate?
Inheritance is often refered to as an IS relation, whereas using an
attribute
is a HAS relation.
If you inherit from file, all operations for files should be
Hi all,
I am trying to write a script that prints out the signatures
of each function call that occurs during the execution of
a second script which is invoked by my program. i.e. if the
inspected program is 'foo.py':
def bar(x,y,z=None) : pass
bar(1,a,bar)
bar(2,int)
Hi,
I need help figuring out how to fix my code. I'm using Python 2.2.3,
and
it keeps telling me invalid syntax in the if name == Nathan line.
The problem is that you indent the if statement. the if/elif/else
statements
are part of the outer block, so they do not need indentation.
Here
Hi,
On 22.06.2005, at 23:18, Michael Barkholt wrote:
Is there any detailed documentation on the structure of Pythons
internals,
besides the source code itself?
More specifically I am looking for information regarding the C parser,
since
I am looking into the viability of using it in
the doc seems to suggest that eval is only for expressions... it says
uses exec for statements, but i don't seem to see a exec function?
Python 2.4 (#1, Dec 30 2004, 08:00:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type help, copyright, credits or license for more
On 16.06.2005, at 20:59, Shankar Iyer ([EMAIL PROTECTED]) wrote:
Hi,
Suppose I have a string, sModuleName, that contains the name of a
module. I now want to see what functions are in that module, but if I
call dir(sModuleName), I instead get the list of operations that can
be done on a
Yah! Finally, I got the thing to work. Here is how I did it.
/* import the module that holds the base class */
PyObject *base_module = PyImport_ImportModule(module_name);
if (!base_module) return;
/* get a pointer to the base class */
PyObject *base_class = PyMapping_GetItemString(
On 13.06.2005, at 13:23, [EMAIL PROTECTED] wrote:
Hi all,
I have a C++ library I call from python. The problem is I have c++
exceptions that i want to be translated to python. I want to be able to
do stuff like:
try:
my_cpp_function()
except cpp_exception_1:
do_stuff
except
Am I stupid or what?
I want to implement a very simple extension class in C (as I did
it many times before...) The python equivalent of my class whould
look like:
class physics_DPD :
def __init__(self,cutoff,friction,noise,dt) :
self.cutoff = cutoff
harold fellermann [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hi all,
I once read that it is possible to use a python base class for a C
extension class.
On 14.06.2005, at 09:29, Grigoris Tsolakidis wrote:
There was good article of how to do this on DDJ home page
On 13.06.2005, at 15:52, Xavier Décoret wrote:
I would like to know if there is for python's classes an equivalent of
the operator= that can be overidden.
Let's say I have
a=A()
and I want to write
a=5
and I want this to change some internal value of a instead of making a
point to a new
to return 'WHERE name LIKE %smith%'I have tried using escapes,
character codes for the % sign, and lots of other gyrations with no
success. The only thing that works is if I modify searchterm first:
searchterm = 'smith'
searchterm ='%'+'smith'+'%'
sql += 'WHERE
Hi all,
I once read that it is possible to use a python base class for a C
extension class. To be precise, I want to achieve the following
behavior:
class PythonClass :
pass
class CClass(PythonClass) :
this class should be implemented as C extension
pass
On 13.06.2005, at 19:23, Terry Reedy wrote:
harold fellermann [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
if you write
a=A()
an instance of class A is created and bound to the local identifier
'a'.
I think it perhaps better to think of the label 'a' being bound
On 07.06.2005, at 16:44, harold fellermann wrote:
import thread
def parentThread() :
lock = thread.allocate_lock()
child = thread.start_new_thread(childThread,(parent,))
lock.acquire()
def childThread(parent) :
parent.lock.acquire
Hi,
I want a reliable way of knowing when the child
thread finished execution so that I can make the main thread wait till
then.
Any ideas?
use a lock. the subthread allocates the lock and releases it after
processing.
the main thread must wait until the lock is released. otherwiese, use
we had some off-group mails. A summary is posted to improve the
knowledge
base of the list.
Prashanth wrote:
Hi,
I can use the threading module but I am just looking if there is a
reliable way using the thread module.
If I use a lock...
Let us assume that the child thread has done a
On 07.06.2005, at 16:43, Ahmad Hosseinzadeh wrote:
Hello,
Im trying to run an external program in my
application. Both are coded in python. I need to write
an independent module that is used in the main
application. Its responsibility is to run the external
program and redirect its stdout
The problem for me is that the pointer p in the last function points
to the arguments:
If a user caller foo(123) - p points to '123'.
What I need is to point it to the whole string received - 'foo
(123)'.
Is there a way I can do this?
no. at least not a simple one. you can obtain the
Hi,
Calling a python method from C++ has the following signature:
PyObject *
PyObject_CallMethod(PyObject *self, char *method_name,
char *arg_format, ...);
I'm having trouble figuring out how to declare self.
Let's say my python file is called stuff.py and is like the
Hi all,
I want to use curses in a server application that provides a GUI for
telnet clients. Therefore, I need the functionality to open and handle
several
screens. Concerning
http://dickey.his.com/ncurses/ncurses-intro.html#init
this can be done using the function newterm(type,ofp,ifp).
On 14.04.2005, at 19:17, Christos TZOTZIOY Georgiou wrote:
On Thu, 14 Apr 2005 18:39:14 +0200, rumours say that harold fellermann
[EMAIL PROTECTED] might have written:
Hi all,
I want to use curses in a server application that provides a GUI for
telnet clients. Therefore, I need the functionality
I have read a text file using the command
lines = myfile.readlines()
and now I want to seach those lines for a particular string. I was
hoping there was a way to find that string in a similar way as
searching simply a simple string. I want to do something like
lines.find.('my particular
Thank you Greg,
I figured most of it out in the meantime, myself. I only differ
from you in one point.
What has to be done, if the function is invoked for an operator
I don't want to define?
Return Py_NotImplemented. (Note that's return, *not* raise.)
I used
PyErr_BadArgument();
return NULL;
What I am wondering is if I have a 2nd init or something similar to
create a vector. Such as what follows and if I can how do I go about
implementing it?
Class vector(point):
def __init___(self, point1, point2):
self.i = point2.get_x() - point1.get_x()
self.j =
Hi all,
I want to implement rich comparision in an extension class. Problem is
I cannot
find good documentation of the richcmpfunc semantics. Given the
signature
richcmpfunc compare(PyObject *,PyObject, int);
I supposed the two objects passed are the ones to be compared.
What is the meaning of
Hello,
I asked this question some time ago, but as I got no answer, so I just
try it a second
time.
I am working on a C extension module that implements a bunch of
classes. Everything
works fine so far, but I cannot find any way to implement class
attributes or inner
classes. Consider you have
Hello,
I just posted this question with a wrong subject... So here again with
a better one.
I am working on a C extension module that implements a bunch of
classes. Everything
works fine so far, but I cannot find any way to implement class
attributes or inner
classes. Consider you have the
I am working on a C extension module that implements a bunch of
classes. Everything
works fine so far, but I cannot find any way to implement class
attributes or inner
classes. Consider you have the following lines of Python :
class Foo :
class Bar :
pass
spam =
I think you could as well, after PyType_Ready() is called, set it
yourself with
PyObject_SetAttrString(FooType, Bar, FooBarType);
You *may* have to cast the FooType and FooBarType to (PyObject *), to
avoid compiler warnings.
I tried this. Its shorter and and works fine, too. thanks for the
On 20.01.2005, at 12:24, Mark English wrote:
I'd like to write a Tkinter app which, given a class, pops up a
window(s) with fields for each attribute of that class. The user
could
enter values for the attributes and on closing the window would be
returned an instance of the class. The actual
Hi all,
I have a problem pickling an extension class. As written in the
Extending/Embedding Manual, I
provided a function __reduce__ that returns the appropreate tuple. This
seams to work fine,
but I still cannot pickle because of the following error:
from model import hyper
g =
On 18.01.2005, at 20:31, Alex Martelli wrote:
harold fellermann [EMAIL PROTECTED] wrote:
File /sw/lib/python2.4/pickle.py, line 760, in save_global
raise PicklingError(
pickle.PicklingError: Can't pickle type 'hyper.PeriodicGrid': it's
not found as hyper.PeriodicGrid
dir(hyper)
['Dir
Hi Tim,
If you have
class Foo(object) :
x = 0
y = 1
foo = Foo()
foo.x # reads either instance or class attribute (class in this case)
foo.x = val # sets an instance attribute (because foo is instance not
class)
Foo.x = val # sets a class attribute
foo.__class.__x = val
have a look at the thread copying classes? some days ago.
what goes for copying goes for pickling also, because the
modules use the same interface.
- harold -
On 13.01.2005, at 13:32, Sebastien Boisgerault wrote:
Hi,
It seems to me that it's not possible with the pickle module
to serialize a class
Hi,
I have a question concerning the Tix file select mechanisms.
Unfortunately,
I have very little experience with neither tk, Tkinter nor Tix.
Somewhere
in my GUI I have a save button. What I want is that pressing the button
opens a file requester. The user can either select a filename or
On 12.01.2005, at 18:35, It's me wrote:
For this code snip:
a=3
b=(1,len(a))[isinstance(a,(list,tuple,dict))]
Why would I get a TypeError from the len function?
because len() works only for sequence and mapping objects:
help(len)
Help on built-in function len in module __builtin__:
len(...)
On 12.01.2005, at 18:35, It's me wrote:
For this code snip:
a=3
b=(1,len(a))[isinstance(a,(list,tuple,dict))]
Why would I get a TypeError from the len function?
the problem is, that (1,len(a)) is evaluated, neither what type a
actually has
(python has no builtin lazy evaluation like ML). You
Hello,
does anyone know a way to set the __doc__ string of a new style class?
Any attempt I tried results in the following error:
Python 2.4 (#1, Dec 30 2004, 08:00:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type help, copyright, credits or license for more information.
On 11.01.2005, at 19:14, Nicolas Pourcelot wrote:
Hello,
I'm new to this mailing list and quite to Pyhon too.
I would like to know how to export the contain of the Canvas object
(Tkinter) in a PNG file ?
Thanks :)
Nicolas Pourcelot
--
http://mail.python.org/mailman/listinfo/python-list
you can
Thank you, Duncan and Steven.
I completely forgot about setattr.
Of course that's the way ... as its name might suggest *g*
What you are doing wrong is attempting to use eval before exhausting
all
the simpler techniques. Why not just call 'setattr'?
setattr(X, 'attr', 5)
BTW, the syntax error is
On 30.12.2004, at 01:24, It's me wrote:
I would not think that a generic deepcopy would work for all cases.
An
object can be as simple as a number, for instance, but can also be as
complex as the universe. I can't imagine anybody would know how to
copy a
complex object otherthen the object
Hi all,
In the documentation of module 'copy' it is said that This version
does not copy types like module, class, function, method, stack trace,
stack frame, file, socket, window, array, or any similar types.
Does anyone know another way to (deep)copy objects of type class? What
is special
Thank you very much. Of course I know how to do it in python. The
problem is that I want to reimplement these classes as a python
extension in C. The question is: how can I add class members (like
e.g. inner classes) to a PyTypeObject defined in a C extension?
- harold -
You can define a class
Hi,
I cannot see any strange behavior. this code works exacly as you and I
suspect:
def otherfunction(x) :
... return x
...
def function(arg=otherfunction(5)) :
... return arg
...
function(3)
3
function()
5
Or is this not what you excepted?
- harold -
On 21.12.2004, at 15:47, [EMAIL
81 matches
Mail list logo