Re: [Python-Dev] Coroutines (PEP 342)

2005-11-14 Thread Phillip J. Eby
At 03:46 PM 11/14/2005 -0700, Bruce Eckel wrote: >I just finished reading PEP 342, and it appears to follow Hoare's >Communicating Sequential Processes (CSP) where a process is a >coroutine, and the communicaion is via yield and send(). It seems that >if you follow that form (and you don't seem for

Re: [Python-Dev] str.dedent

2005-11-14 Thread Greg Ewing
James Y Knight wrote: > ITYM you mean "If only python were lisp". (macros, or even reader macros) No, I mean it would be more satisfying if there were a syntax for expressing multiline string literals that didn't force it to be at the left margin. The lack of such in such an otherwise indentatio

Re: [Python-Dev] str.dedent

2005-11-14 Thread Martin v. Löwis
Noam Raphael wrote: > There's no reason why multilined strings that are used only once > should be defined at the beginning of a program (think about a simple > CGI script, which prints HTML parts in a function.) I find that simple CGI scripts are precisely the example *for* putting multi-line str

[Python-Dev] Coroutines (PEP 342)

2005-11-14 Thread Bruce Eckel
I just finished reading PEP 342, and it appears to follow Hoare's Communicating Sequential Processes (CSP) where a process is a coroutine, and the communicaion is via yield and send(). It seems that if you follow that form (and you don't seem forced to, pythonically), then synchronization is not an

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Noam Raphael
On 11/15/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > If you want to write portable code that keeps things running "in the > background" while the users hack away at the standard interactive > prompt, InputHook won't help you. > So probably it should be improved, or changed a bit, to work also on

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Fredrik Lundh
Noam Raphael wrote: > It didn't. Strange freezes started to appear, only when working from > IDLE. This made me investigate a bit, and I've found that Tkinter > isn't run from a seperate thread - the dooneevent() function is called > repeatedly by PyOS_InputHook while the interpreter is idle. rep

Re: [Python-Dev] str.dedent

2005-11-14 Thread Noam Raphael
On 11/14/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > so is putting the string constant in a global variable, outside the scope > you're in, like you'd do with any other constant. Usually when I use a constant a single time, I write it where I use it, and don't give it a name. I don't do: messa

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Noam Raphael
On 11/14/05, Michiel Jan Laurens de Hoon <[EMAIL PROTECTED]> wrote: > Ronald Oussoren wrote: > > > I wonder why nobody has suggested a seperate thread for managing the > > GUI and > > using the hook in Python's event loop to issue the call to update_plot. > > > Ha. That's probably the best solution

Re: [Python-Dev] str.dedent

2005-11-14 Thread Fredrik Lundh
Noam Raphael wrote: > That's a theoretical argument. In practice, if you do it in the > parser, you have two options: > > 1. Automatically dedent all strings. > 2. Add a 'd' or some other letter before the string. > > Option 1 breaks backwards compatibility, and makes the parser do > unexpected th

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread skip
Michiel> 1) Currently, there's only one PyOS_InputHook. So we're stuck Michiel>if we find that some other extension module already set Michiel>PyOS_InputHook. An easy solution would be to have an Michiel>PyOS_AddInputHook/PyOS_RemoveInputHook API, and let Python Mic

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Aahz
On Sun, Nov 13, 2005, Josiah Carlson wrote: > > I personally like Edward Loper's idea of just running your own event > handler which deals with drawing, suspend/resume, etc... > >> If, however, Python contains an event loop that takes care of events as >> well as Python commands, redrawing won't

Re: [Python-Dev] str.dedent

2005-11-14 Thread Noam Raphael
Just two additional notes: On 9/15/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > -1 > > Let it continue to live in textwrap where the existing pure python code > adequately serves all string-like objects. It's not worth losing the > duck typing by attaching new methods to str, unicode, Use

Re: [Python-Dev] str.dedent

2005-11-14 Thread Noam Raphael
On 11/14/05, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > We have to draw a line somewhere - otherwise you could > just as well add all functions that accept single > string arguments as methods to the basestring > sub-classes. Please read my first post in this thread - I think there's more reason f

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Michiel Jan Laurens de Hoon
Ronald Oussoren wrote: > I wonder why nobody has suggested a seperate thread for managing the > GUI and > using the hook in Python's event loop to issue the call to update_plot. > Ha. That's probably the best solution I've heard so far, short of adding a Tcl-like event loop API to Python. There

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Ronald Oussoren
On 14-nov-2005, at 8:16, Josiah Carlson wrote: > > I personally like Edward Loper's idea of just running your own event > handler which deals with drawing, suspend/resume, etc... > >> If, however, Python contains an event loop that takes care of >> events as >> well as Python commands, redrawin

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Ronald Oussoren
On 14-nov-2005, at 16:00, [EMAIL PROTECTED] wrote: > > Ronald> ... except when the GUI you're using doesn't expose (or > even > Ronald> use) a file descriptor that you can use with select. > Not all the > Ronald> world is Linux. > > Can you be more specific? Are you referring to

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Fredrik Lundh
Michiel Jan Laurens de Hoon wrote: > This is exactly the problem. Drawing one picture may consist of many > Python commands to draw the individual elements (for example, several > graphs overlaying each other). We don't know where in the window each > element will end up until we have the list of

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Fredrik Lundh
Michiel Jan Laurens de Hoon wrote: > >Did you read my reply? ipython, based on code.py, implements a few simple > >threading tricks (they _are_ simple, since I know next to nothing about > >threading) and gives you interactive use of PyGTK, WXPython and PyQt > >applications in a manner similar to

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Michiel Jan Laurens de Hoon
[EMAIL PROTECTED] wrote: >Ronald> ... except when the GUI you're using doesn't expose (or even >Ronald> use) a file descriptor that you can use with select. Not all the >Ronald> world is Linux. > >Can you be more specific? Are you referring to Windows? I'm not suggesting >you'd be ab

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-14 Thread Ulrich Berning
Mark Hammond schrieb: >>release. The main reason why I changed the import behavior was >>pythonservice.exe from the win32 extensions. pythonservice.exe imports >>the module that contains the service class, but because >>pythonservice.exe doesn't run in optimized mode, it will only import a >>.py o

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread skip
Ronald> ... except when the GUI you're using doesn't expose (or even Ronald> use) a file descriptor that you can use with select. Not all the Ronald> world is Linux. Can you be more specific? Are you referring to Windows? I'm not suggesting you'd be able to use the same exact implem

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-14 Thread Guido van Rossum
On 11/14/05, Ulrich Berning <[EMAIL PROTECTED]> wrote: > >You seem to forget the realities of backwards compatibility. While > >there are ways to cache bytecode without having multiple extensions, > >we probably can't do that until Python 3.0. > > > Please can you explain what backwards compatibili

Re: [Python-Dev] str.dedent

2005-11-14 Thread M.-A. Lemburg
Gareth McCaughan wrote: > On Sunday 2005-11-13 17:43, Marc-Andre Lemburg wrote: > > [Noam Raphael:] > >>>The idea is to add a method called "dedent" to strings. It would do >>>exactly what the current textwrap.indent function does. > > > [Marc-Andre:] > >>You are missing a point here: string

Re: [Python-Dev] Inconsistent behaviour in import/zipimport hooks

2005-11-14 Thread Ulrich Berning
Guido van Rossum schrieb: >On 11/11/05, Ulrich Berning <[EMAIL PROTECTED]> wrote: > > >>For instance, nobody would give the output of a C compiler a different >>extension when different compiler flags are used. >> >> > >But the usage is completely different. With C you explicitly manage >whe

Re: [Python-Dev] str.dedent

2005-11-14 Thread Gareth McCaughan
On Sunday 2005-11-13 17:43, Marc-Andre Lemburg wrote: [Noam Raphael:] > > The idea is to add a method called "dedent" to strings. It would do > > exactly what the current textwrap.indent function does. [Marc-Andre:] > You are missing a point here: string methods were introduced > to make switchi

Re: [Python-Dev] Event loops, PyOS_InputHook, and Tkinter

2005-11-14 Thread Martin v. Löwis
Michiel Jan Laurens de Hoon wrote: > If, however, Python contains an event loop that takes care of events as > well as Python commands, redrawing won't happen until Python has > executed all plot commands -- so no repainting in vain here. Ah, I think now I understand the problem. It seems that y