Re: [Python-Dev] The decorator module

2005-05-09 Thread Raymond Hettinger
[Michele Simionato] Is there in the plans any facility to copy functions? Currently I am doing def copyfunc(func): Creates an independent copy of a function. c = func.func_code nc = new.code(c.co_argcount, c.co_nlocals, c.co_stacksize, c.co_flags, c.co_code,

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
Ron Adam wrote: There seems to be some confusion as to weather or not 'for's will do finalizing. So I was trying to stress I think regular 'for' loops should not finalize. They should probably give an error if an object with an try-finally in them or an __exit__ method. But if the

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Josiah Carlson
Ron Adam [EMAIL PROTECTED] wrote: The argument over whether blocks should loop, I believe has been had; they should. The various use cases involve multi-part transactions and such. I think so now too, I had thought as Nick does earlier this week that the non-looping version was

[Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Jim Jewett
Nick Coghlan ncoghlan at gmail.com wrote: Josiah Carlson wrote: This has the benefit that an arbitrary block of code can be named, and a named TerminateBlock used to exit it. ... I suspect any such implementation is going to need to use exceptions for the guts of the flow control, even if

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Eric Nieuwland
Greg Ewing wrote: Ron Adam wrote: There seems to be some confusion as to weather or not 'for's will do finalizing. So I was trying to stress I think regular 'for' loops should not finalize. They should probably give an error if an object with an try-finally in them or an __exit__ method.

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Josiah Carlson
Jim Jewett [EMAIL PROTECTED] wrote: Nick Coghlan ncoghlan at gmail.com wrote: Josiah Carlson wrote: This has the benefit that an arbitrary block of code can be named, and a named TerminateBlock used to exit it. ... I suspect any such implementation is going to need to use

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Josiah Carlson
Ron Adam [EMAIL PROTECTED] wrote: Josiah Carlson wrote: Ron Adam [EMAIL PROTECTED] wrote: There's also the possibility to use conditional looping based on the value returned from the generator. do VAR from EXPR if VAR==CONST: BLOCK This is a bit verbose, but it

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Ron Adam
Josiah Carlson wrote: Ron Adam [EMAIL PROTECTED] wrote: Yes, so just do [VAR from] EXPR1: Regardless of the 'finalization' syntax, I'm talking about the fact that including extra 'if EXPR' or 'while EXPR' is not going to be an option. Yes, I meant for the syntax to be the shorter form,

Re: [Python-Dev] New Py_UNICODE doc

2005-05-09 Thread Martin v. Löwis
M.-A. Lemburg wrote: On sre character classes: I don't think that these provide a good approach to XML lexical classes - custom functions or methods or maybe even a codec mapping the characters to their XML lexical class are much more efficient in practice. That isn't my experience:

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Nick Coghlan
Raymond Hettinger wrote: [Nick Coghlan] The number of good use cases for a looping block statement currently stands at exactly 1 (auto_retry). Every other use case suggested (locking, opening, suppressing, etc) involves factoring out try statement boiler plate that is far easier to

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
Ron Adam wrote: That's sort of why I'm against changing 'for', and for adding the new loop/block. I see it as a loop with a higher level of abstraction. A new tool to be used in new ways, but I want to keep my old dependable tools too. But if there's too much overlap in functionality

Re: [Python-Dev] PEP 340: Deterministic Finalisation (new PEP draft, either a competitor or update to PEP 340)

2005-05-09 Thread Greg Ewing
Josiah Carlson wrote: 2. Standard for/while loops should not be finalized in a timely fashion, because testing for the proper methods would necessarily slow down large amounts of current Python, so should be left to the garbage collector. I'm not convinced about that. If implemented properly,

[Python-Dev] Merging PEP 310 and PEP 340-redux?

2005-05-09 Thread Guido van Rossum
Apologies if this has been discovered and rejected already; I've had to skip most of the discussions but this though won't leave my head... So PEP 310 proposes this: with VAR = EXPR: BLOCK translated to VAR = EXPR\ if hasattr(VAR, __enter__):