Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-26 Thread Greg Ewing
Michael Chermside wrote: I've been following this conversation, and it sounds to me as if we are stumbling about in the dark, trying to feel our way toward something very useful and powerful. I think Jim is right, what we're feeling our way toward is macros. I considered saying something like that

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-26 Thread Greg Ewing
Michael Chermside wrote: if the answer is that we want to prohibit nothing, then the right solution is macros. I'm not sure about that. Smalltalk manages to provide very reasonable-looking user-defined control structures without using compile-time macros, just normal runtime evaluation together

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Brett C.
Greg Ewing wrote: Brett C. wrote: And before anyone decries the fact that this might confuse a newbie (which seems to happen with every advanced feature ever dreamed up), remember this will not be meant for a newbie but for someone who has experience in Python and iterators at the

Re: [Python-Dev] site enhancements (request for review)

2005-04-26 Thread Bob Ippolito
On Apr 26, 2005, at 1:12 AM, Greg Ewing wrote: Bob Ippolito wrote: A few weeks ago I put together a patch to site.py for Python 2.5 http://python.org/sf/1174614 that solves three major deficiencies: [concerning .pth files] While we're on the subject of .pth files, what about the idea of

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Guido van Rossum
[Greg Ewing] I like the general shape of this, but I have one or two reservations about the details. That summarizes the feedback so far pretty well. I think we're on to something. And I'm not too proud to say that Ruby has led the way here to some extent (even if Python's implementation would

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-26 Thread Rodrigo Dias Arruda Senra
[ Michael Walter ]: A couple of examples out of my tired head (solely from a user perspective) :-) Embedding domain specific language (ex.: state machine): ... Embedding domain specific language (ex.: markup language): ... Embedding domain-specific language (ex.: badly-designed

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Greg Ewing
Brett C. wrote: It executes the body, calling next() on the argument name on each time through until the iteration stops. But that's no good, because (1) it mentions next(), which should be an implementation detail, and (2) it talks about iteration, when most of the time the high-level intent has

[Python-Dev] Re: anonymous blocks

2005-04-26 Thread Reinhold Birkenfeld
Guido van Rossum wrote: [Greg Ewing] I like the general shape of this, but I have one or two reservations about the details. That summarizes the feedback so far pretty well. I think we're on to something. And I'm not too proud to say that Ruby has led the way here to some extent (even if

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Greg Ewing
Guido van Rossum wrote: [Greg Ewing] * It seems to me that this same exception-handling mechanism would be just as useful in a regular for-loop, and that, once it becomes possible to put 'yield' in a try-statement, people are going to *expect* it to work in for-loops as well. (You can already put

[Python-Dev] Re: anonymous blocks

2005-04-26 Thread Reinhold Birkenfeld
Nick Coghlan wrote: Guido van Rossum wrote: [snip] - I think there's a better word than Flow, but I'll keep using it until we find something better. How about simply reusing Iteration (ala StopIteration)? Pass in 'ContinueIteration' for 'continue' Pass in 'BreakIteration' for

[Python-Dev] Removing --with-wctype-functions support

2005-04-26 Thread S . Çağlar Onur
Hi; I just subscribed this list, so i don't know whether this discussed before. If so, sorry. I want to know status of http://mail.python.org/pipermail/python-dev/2004-December/050193.html this thread. Will python remove wctype functions support from its core? If it will, what about

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Nick Coghlan
Reinhold Birkenfeld wrote: Nick Coghlan wrote: Guido van Rossum wrote: [snip] - I think there's a better word than Flow, but I'll keep using it until we find something better. How about simply reusing Iteration (ala StopIteration)? Pass in 'ContinueIteration' for 'continue' Pass in

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Michael Hudson
Whew! This is a bit long... On 25 Apr 2005, at 00:57, Guido van Rossum wrote: After reading a lot of contributions (though perhaps not all -- this thread seems to bifurcate every time someone has a new idea :-) I haven't read all the posts around the subject, I'll have to admit. I've read the

[Python-Dev] Re: Re: Re: anonymous blocks

2005-04-26 Thread Terry Reedy
Greg Ewing [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Terry Reedy wrote: The part you quoted was by Nick Coghlan, not me, as indicated by the (now ) instead of (which would now be ) in front of the lines. Not supporting iterables makes it harder to write a class which is

RE: [Python-Dev] defmacro

2005-04-26 Thread Andrew Koenig
This doesn't feel right to me. By that argument, people would want to improve (mapcar (lambda (x) (car x)) list-of-lists) to (mapcar list-of-lists (x) (car x)) Have you ever heard someone complain about that lambda, though? Wel Shouldn't you have written (mapcar

Re: [Python-Dev] Re: Caching objects in memory

2005-04-26 Thread Facundo Batista
On 4/25/05, Guido van Rossum [EMAIL PROTECTED] wrote: I was in my second class of the Python workshop I'm giving here in one Argentine University, and I was explaining how to think using name/object and not variable/value. Using id() for being pedagogic about the objects, the kids saw

Re: [Python-Dev] Re: Caching objects in memory

2005-04-26 Thread Facundo Batista
On 4/26/05, Greg Ewing [EMAIL PROTECTED] wrote: Also, string literals that resemble Python identifiers are often interned, although this is not guaranteed. And this only applies to literals, not strings constructed dynamically by the program (unless you explicitly apply intern() to them).

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Michael Hudson
Samuele Pedroni [EMAIL PROTECTED] writes: Michael Hudson wrote: The history of iterators and generators could be summarized by saying that an API was invented, then it turned out that in practice one way of implementing them -- generators -- was almost universally useful. This proposal

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread ron adam
Hi, this is my first post here and I've been following this very interesting discussion as is has developed. A really short intro about me, I was trained as a computer tech in the early 80's... ie. learned transistors, gates, logic etc... And so my focus tends to be from that of a

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Aahz
On Tue, Apr 26, 2005, Guido van Rossum wrote: Now there's one more twist, which you may or may not like. Presumably (barring obfuscations or bugs) the handling of BreakFlow and ContinueFlow by an iterator (or generator) is consistent for all uses of that particular iterator. For example

[Python-Dev] atexit missing an unregister method

2005-04-26 Thread Nick Jacobson
I was looking at the atexit module the other day; it seems like an elegant way to ensure that resources are cleaned up (that the garbage collector doesn't take care of). But while you can mark functions to be called with the 'register' method, there's no 'unregister' method to remove them from

Re: [Python-Dev] atexit missing an unregister method

2005-04-26 Thread Guido van Rossum
On 4/26/05, Nick Jacobson [EMAIL PROTECTED] wrote: I was looking at the atexit module the other day; it seems like an elegant way to ensure that resources are cleaned up (that the garbage collector doesn't take care of). But while you can mark functions to be called with the 'register'

RE: [Python-Dev] atexit missing an unregister method

2005-04-26 Thread Raymond Hettinger
[Nick Jacobson] I was looking at the atexit module the other day; it seems like an elegant way to ensure that resources are cleaned up (that the garbage collector doesn't take care of). But while you can mark functions to be called with the 'register' method, there's no 'unregister' method

[Python-Dev] Problem with embedded python

2005-04-26 Thread Ugo Di Girolamo
I have the following code, that seems to make sense to me. However, it crashes about 1/3 of the times. My platform is Python 2.4.1 on WXP (I tried the release version from the msi and the debug version built by me, both downloaded today to have the latest version). The crash happens

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Nick Coghlan
Phillip J. Eby wrote: At 09:12 PM 4/24/05 -0600, Steven Bethard wrote: I guess it would be helpful to see example where the looping with-block is useful. Automatically retry an operation a set number of times before hard failure: with auto_retry(times=3):

[Python-Dev] Re: anonymous blocks vs scope-collapse

2005-04-26 Thread Jim Jewett
(2) Add a way to say Make this function I'm calling use *my* locals and globals. This seems to meet all the agreed-upon-as-good use cases, but there is disagreement over how to sensibly write it. The calling function is the place that could get surprised, but people who want thunks seem to

Re: [Python-Dev] Problem with embedded python

2005-04-26 Thread Martin v. Löwis
Ugo Di Girolamo wrote: What am I doing wrong? This is not the forum to ask this question, please use python-list@python.org instead. Regards, Martin ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev

Re: [Python-Dev] Re: anonymous blocks vs scope-collapse

2005-04-26 Thread Paul Moore
On 4/26/05, Jim Jewett [EMAIL PROTECTED] wrote: I'm not sure I understand this. The preferred way would be to just stick the keyword before the call. Using 'collapse', it would look like: def foo(b): c=a def bar(): a=a1 collapse foo(b1) print b,

[Python-Dev] python.org crashing Mozilla?

2005-04-26 Thread Paul Dubois
Three different computers running Linux / Mozilla are crashing Mozilla when directed to python.org. A Netscape works ok. Are we hacked or are we showing off? ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Re: anonymous blocks vs scope-collapse

2005-04-26 Thread Guido van Rossum
[Jim Jewett] (2) Add a way to say Make this function I'm calling use *my* locals and globals. This seems to meet all the agreed-upon-as-good use cases, but there is disagreement over how to sensibly write it. The calling function is the place that could get surprised, but people who

Re: [Python-Dev] Re: anonymous blocks vs scope-collapse

2005-04-26 Thread Guido van Rossum
[Paul Moore] *YUK* I spent a long time staring at this and wondering where did b come from? You'd have to come up with a very compelling use case to get me to like this. I couldn't have said it better. I said it longer though. :-) -- --Guido van Rossum (home page:

Re: [Python-Dev] python.org crashing Mozilla?

2005-04-26 Thread Fred L. Drake, Jr.
On Tuesday 26 April 2005 16:53, Paul Dubois wrote: Three different computers running Linux / Mozilla are crashing Mozilla when directed to python.org. A Netscape works ok. Are we hacked or are we showing off? Paul, My Firefox 1.0.2 is fine. What version(s) of Mozilla, and what host

[Python-Dev] Re: a few SF bugs which can (probably) be closed

2005-04-26 Thread Terry Reedy
Ilya Sandler [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Here a few sourceforge bugs which can probably be closed: [ 1168983 ] : ftplib.py string index out of range Original poster reports that the problem disappeared after a patch committed by Raymond Not clear to me if this

[Python-Dev] scope-collapse

2005-04-26 Thread Jim Jewett
[Jim Jewett] (2) Add a way to say Make this function I'm calling use *my* locals and globals. This seems to meet all the agreed-upon-as-good use cases, but there is disagreement over how to sensibly write it. [Guido] What happens to names that have a different meaning in each scope?

[Python-Dev] Re: [Pythonmac-SIG] zipfile still has 2GB boundary bug

2005-04-26 Thread Charles Hartman
Someone should think about rewriting the zipfile module to be less hideous, include a repair feature, and be up to date with the latest specifications http://www.pkware.com/company/standards/appnote/. -- and allow *deleting* a file from a zipfile. As far as I can tell, you now can't (except by

Re: [Python-Dev] atexit missing an unregister method

2005-04-26 Thread Greg Ewing
Nick Jacobson wrote: But while you can mark functions to be called with the 'register' method, there's no 'unregister' method to remove them from the stack of functions to be called. You can always build your own mechanism for managing cleanup functions however you want, and register a single

[Python-Dev] Re: scope-collapse (was: anonymous blocks)

2005-04-26 Thread Robert Brewer
[Jim Jewett] (2) Add a way to say Make this function I'm calling use *my* locals and globals. This seems to meet all the agreed-upon-as-good use cases, but there is disagreement over how to sensibly write it. The calling function is the place that could get surprised, but people who want

Re: [Python-Dev] defmacro

2005-04-26 Thread Greg Ewing
Stephen J. Turnbull wrote: This doesn't feel right to me. By that argument, people would want to improve (mapcar (lambda (x) (car x)) list-of-lists) to (mapcar list-of-lists (x) (car x)) I didn't claim that people would feel compelled to eliminate all uses of lambda; only that, in those cases

[Python-Dev] defmacro (was: Anonymous blocks)

2005-04-26 Thread Jim Jewett
(3) Add macros. We still have to figure out how to limit their obfuscation. nobody has given even a *remotely* plausible mechanism for how exactly you would get code executed at compile time. macros can (and *possibly* should) be evaluated at run-time. We must still have very

Re: [Python-Dev] defmacro (was: Anonymous blocks)

2005-04-26 Thread Greg Ewing
Jim Jewett wrote: I had been thinking that the typical use would be during function (or class) definition. The overhead would be similar to that of decorators, and confined mostly to module loading. But that's too late, unless you want to resort to bytecode hacking. By the time the module is

Re: [Python-Dev] scope-collapse

2005-04-26 Thread Guido van Rossum
[Jim jewett] The pretend-it-is-a-generator proposals try to specify that only certain names will be shared, in only certain ways. Huh? I don't see it this way. There is *no* sharing between the frame of the generator and the frame of the block. The block is a permanent part of the frame

Re: [Python-Dev] Re: [Pythonmac-SIG] zipfile still has 2GB boundary bug

2005-04-26 Thread Guido van Rossum
Someone should think about rewriting the zipfile module to be less hideous, include a repair feature, and be up to date with the latest specifications http://www.pkware.com/company/standards/appnote/. -- and allow *deleting* a file from a zipfile. As far as I can tell, you now can't

Re: [Python-Dev] Re: scope-collapse (was: anonymous blocks)

2005-04-26 Thread Jim Jewett
On 4/26/05, Robert Brewer [EMAIL PROTECTED] wrote: [Jim] Absolutely. Even giving up the XXX_FAST optimizations would still require new bytecode to not assume them. I'm afraid I'm only familiar with CPython, but wouldn't callee locals just map to XXX_FAST indices via the caller's co_names

Re: [Python-Dev] Re: [Pythonmac-SIG] zipfile still has 2GB boundary bug

2005-04-26 Thread Bob Ippolito
On Apr 26, 2005, at 8:24 PM, Guido van Rossum wrote: Someone should think about rewriting the zipfile module to be less hideous, include a repair feature, and be up to date with the latest specifications http://www.pkware.com/company/standards/appnote/. -- and allow *deleting* a file from a

Re: [Python-Dev] Re: [Pythonmac-SIG] zipfile still has 2GB boundary bug

2005-04-26 Thread Alan McIntyre
Bob Ippolito wrote: One of the most useful things that could happen to the zipfile module would be a stream interface for both reading and writing. Right now it's slow and memory hungry when dealing with large chunks. The use case that lead me to fix this bug is a tool that archives video

Re: [Python-Dev] Re: anonymous blocks vs scope-collapse

2005-04-26 Thread Greg Ewing
I don't think this proposal has any chance as long as it's dynamically scoped. It mightn't be so bad if it were lexically scoped, i.e. a special way of defining a function so that it shares the lexically enclosing scope. This would be implementable, since the compiler has all the necessary

Re: [Python-Dev] Re: Caching objects in memory

2005-04-26 Thread Greg Ewing
Facundo Batista wrote: Aargh! Bad explanation. Or at least you're missing something: Not really. It's easier for me to show that id(3) is always the same and id([]) not, and let the kids see that's not so easy and you'll have to look deeper if you want to know better. I think Guido was saying that

Re: [Python-Dev] defmacro

2005-04-26 Thread Stephen J. Turnbull
Andrew == Andrew Koenig [EMAIL PROTECTED] writes: Andrew Wel Shouldn't you have written Andrew (mapcar car list-of-lists) Andrew or am I missing something painfully obvious? Greg should have written (with-file foo/blarg 'do-something-with) too. I guess I should

Re: [Python-Dev] Re: [Pythonmac-SIG] zipfile still has 2GB boundary bug

2005-04-26 Thread Shane Hathaway
Bob Ippolito wrote: The zipfile module is good enough to create input files for zipimport.. which is well tested and generally works -- barring the fact that zipimport has quite a few rough edges of its own. I certainly wouldn't recommend it for any heavy duty tasks in its current state.

Re: [Python-Dev] Re: [Pythonmac-SIG] zipfile still has 2GB boundary bug

2005-04-26 Thread Guido van Rossum
Please don't propose a grand rewrite (even it's only a single module). Given that the API is mostly sensible, please propose gradual refactoring of the implementation, perhaps some new API methods, and so on. Don't throw away the work that went into making it work in the first place!

Re: [Python-Dev] site enhancements (request for review)

2005-04-26 Thread Greg Ewing
Guido van Rossum wrote: I do that all the time without .pth files -- I just put all the common modules in a package and place the package in the directory containing the main .py files. That's fine as long as you're willing to put all the main .py files together in one directory, with everything

Re: [Python-Dev] Re: anonymous blocks

2005-04-26 Thread Guido van Rossum
[Greg Ewing] * It seems to me that this same exception-handling mechanism would be just as useful in a regular for-loop, and that, once it becomes possible to put 'yield' in a try-statement, people are going to *expect* it to work in for-loops as well. [Guido] (You can already put a yield