Re: PyCFunction_New(): to Py_DECREF() or not to Py_DECREF()

2009-12-26 Thread Ecir Hana
On Dec 27, 3:15 am, Benjamin Peterson wrote: > Yes, you still own the reference to the function. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

PyCFunction_New(): to Py_DECREF() or not to Py_DECREF()

2009-12-26 Thread Ecir Hana
Hello, if creating new CFunction PyObject *function = PyCFunction_New(function_name, NULL); and then this is the only thing which uses it ("dictionary" stays alive...) PyDict_SetItemString(dictionary, "function", function); do I have to Py_DECREF(function) or not? -- http://mail.python.org/

Re: Redirect stdout to a buffer [Errno 9]

2009-12-10 Thread Ecir Hana
I tried to replace official Python dll with the one built with MinGW and it works. The problem is, that port is very old and so far it seems that official support for building Python under MinGW is nowhere near. I really don't want to use MSVC, so if there's any other way around this, please, let

Re: Redirect stdout to a buffer [Errno 9]

2009-11-18 Thread Ecir Hana
On Nov 17, 6:51 am, "Gabriel Genellina" wrote: > > The code below now reads from the pipe everything that has been written --   > except from Python :( Thanks a lot for the fine code! So far I don't know why it fails to print from Python - I'll post here any news I get... -- http://mail.python.

Re: Redirect stdout to a buffer [Errno 9]

2009-11-16 Thread Ecir Hana
On Nov 16, 7:21 pm, "Gabriel Genellina" wrote: > En Mon, 16 Nov 2009 14:17:52 -0300, Ecir Hana   > escribió: > > >> I'm trying to write a simple Win32 app, which may run some Python > >> scripts. Since it is a Windows GUI app, I would like to redire

Re: Redirect stdout to a buffer [Errno 9]

2009-11-16 Thread Ecir Hana
On Nov 15, 5:28 pm, Ecir Hana wrote: > Hello, > > I'm trying to write a simple Win32 app, which may run some Python > scripts. Since it is a Windows GUI app, I would like to redirect all > output (Python print, C printf, fprinf stderr, ...) to a text area > inside the a

Redirect stdout to a buffer

2009-11-15 Thread Ecir Hana
Hello, I'm trying to write a simple Win32 app, which may run some Python scripts. Since it is a Windows GUI app, I would like to redirect all output (Python print, C printf, fprinf stderr, ...) to a text area inside the app. In other words, I'm trying to log all the output from the app (C, Python)

Re: Distributing Python environment

2009-09-14 Thread Ecir Hana
I see, thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list

Distributing Python environment

2009-09-13 Thread Ecir Hana
Hello, I have an app which I would like to extend with Python. I I saw how to embed the interpreter into C. If I bundle my app with the Python lib (say, python26.dll) I can PyRun_SimpleString() some code. My question is, how do I bundle the rest of the libraries (site, os, elementtree, random, ...)

Re: Executing python script stored as a string

2009-09-01 Thread Ecir Hana
On Sep 1, 11:32 am, Steven D'Aprano wrote: > > But I don't quite understand why is it security > > risk. How is it different to run: > > exec 'format(your_hdd)' > > than: > > /bin/python format.py > > ? > > It's not different. But read what I said -- "if the string is coming from > an UNTRUSTED so

Re: Executing python script stored as a string

2009-09-01 Thread Ecir Hana
On Sep 1, 5:31 am, Steven D'Aprano wrote: > But are you sure you really want to take this approach? exec is up to ten > times slower than just executing the code directly. Oh, you mean because of parsing and compiling? But otherwise it's as fast as regular python? That's perfectly ok. Or maybe

Re: Executing python script stored as a string

2009-09-01 Thread Ecir Hana
On Sep 1, 5:31 am, Steven D'Aprano wrote: > > You can pass in a global and local namespaces to exec as arguments: > > >>> x = 4 > >>> ns = {'x': 4} > >>> exec "x += 1" in ns > >>> x > 4 > >>> ns['x'] > > 5 > > See the docs for details. Thanks! This is very useful! > You can copy the parts of the

Executing python script stored as a string

2009-08-31 Thread Ecir Hana
Hello, please, how to execute a python script stored as a string? But let me impose several limitations, so simple "exec" wont work: - if I understood it correctly defining a function in the string and exec-ing it created the function in current scope. This is something I really don't want - sim

Re: Inter-process communication, how? Part 2

2007-12-23 Thread ecir . hana
On Dec 23, 10:30 am, "Guilherme Polo" <[EMAIL PROTECTED]> wrote: > 2007/12/22, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > > Hello, > > > just to recap: last time I asked how to do an interprocess > > communitation, between one Manager process (graphical beckend) and > > some Worker processes. > > >

Re: Inter-process communication, how? Part 2

2007-12-23 Thread ecir . hana
On Dec 23, 4:54 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sat, 22 Dec 2007 17:56:05 -0800 (PST), [EMAIL PROTECTED] declaimed > the following in comp.lang.python: > > > just to recap: last time I asked how to do an interprocess > > communitation, between one Manager process (graphical be

Inter-process communication, how? Part 2

2007-12-22 Thread ecir . hana
Hello, just to recap: last time I asked how to do an interprocess communitation, between one Manager process (graphical beckend) and some Worker processes. I decided to go with sockets, thanks for replies, once more. However, I would like to ask another thing: I would like to collect everyting w

Re: Inter-process communication, how?

2007-12-16 Thread ecir . hana
Just for the record: http://www.amk.ca/python/howto/sockets/ "Of the various forms of IPC (Inter Process Communication), sockets are by far the most popular. On any given platform, there are likely to be other forms of IPC that are faster, but for cross-platform communication, sockets are about t

Re: Inter-process communication, how?

2007-12-16 Thread ecir . hana
On Dec 16, 6:38 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > > Read the details for subprocess.Popen() again... > > """ > /args/ should be a string, or a sequence of program arguments. The > program to execute is normally the first item in the args sequence or > string, but can be e

Re: Inter-process communication, how?

2007-12-16 Thread ecir . hana
On Dec 16, 5:24 am, John Machin <[EMAIL PROTECTED]> wrote: > > Yes. Consider this: If you were to run your calculation script from > the shell prompt [strongly recommended during testing], how would you > tell it the name of the file? Now look at the docs again. > File arguments! Of course, totall

Re: Inter-process communication, how?

2007-12-15 Thread ecir . hana
On Dec 16, 2:42 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > Have you perused and been perplexed by the "Is Python a Scripting > Language" thread? Oh, no!! Script as in "shell script". > > Question: Are you creating both scripts from scratch? > Yes? Yes. Then you can de

Inter-process communication, how?

2007-12-15 Thread ecir . hana
Hi, let's say I have two scripts: one does some computations and the other one is a graphical front end for launching the first one. And both run in separate processes (front end runs and that it spawns a subprocess with the computation). Now, if the computation has a result I would like to display

Re: yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-16 Thread ecir . hana
On Apr 17, 3:51 am, [EMAIL PROTECTED] wrote: > I'm reading the docs now and I stumbled upon something: > section "15.3 threading -- Higher-level threading interface" mensions > a class "local", in which "... Thread-local data are data whose values > are thread specific. ..." > > Does it mean, I can

Re: yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-16 Thread ecir . hana
I'm reading the docs now and I stumbled upon something: section "15.3 threading -- Higher-level threading interface" mensions a class "local", in which "... Thread-local data are data whose values are thread specific. ..." Does it mean, I can create global variables whose changing is thread- safe?

Re: yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-16 Thread ecir . hana
On Apr 16, 5:36 pm, "Jason" <[EMAIL PROTECTED]> wrote: > On Apr 16, 7:28 am, [EMAIL PROTECTED] wrote: > > > > > On Apr 16, 3:05 am, Paul Rubin wrote: > > > > [EMAIL PROTECTED] writes: > > > > > Please, can you elaborate further, I'm not sure if I understood. > > > > Shoul

Re: yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-16 Thread ecir . hana
On Apr 16, 3:05 am, Paul Rubin wrote: > [EMAIL PROTECTED] writes: > > > Please, can you elaborate further, I'm not sure if I understood. > > Should I lock global variables i, j during the execution of run()? In > > that case I have to apologize, I showed rather simplified

Re: yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-15 Thread ecir . hana
On Apr 15, 8:07 pm, Paul Rubin wrote: > That is total madness. Just use a normal object or dictionary with a lock. Please, can you elaborate further, I'm not sure if I understood. Should I lock global variables i, j during the execution of run()? In that case I have to

yield, curry, mix-in, new.function, global, closure, .... what will work?

2007-04-15 Thread ecir . hana
Dear list, maybe I'm overlooking something obvious or this is not possible at all or I don't know. Please, consider the following code: ## insert here anything you like def changer(): change_i('changed_i') change_j('changed_j') def run(i='', j=''): ## insert here anything you lik