[Python-Dev] PEP 342 - Enhanced Iterators

2005-06-13 Thread Delaney, Timothy C (Timothy)
There's a thread on c.l.py at the moment (Controlling a generator the pythonic way) which is basically coming up with PEP 342. I've pointed them to PEP 342, but it's made me think that the name of the PEP could better indicate what it does. I propose Coroutines via Enhanced Iterators. Tim

Re: [Python-Dev] PEP 343 rewrite complete

2005-06-02 Thread Delaney, Timothy C (Timothy)
Phillip J. Eby wrote: That's not a bug, it's a feature. If the object doesn't have a 'close()' method, clearly it doesn't need to be closed. If it's the wrong object for what you're using it for in the body of the 'with' block, it'll show up there, so this doesn't hide any errors.

Re: [Python-Dev] Chained Exceptions

2005-05-12 Thread Delaney, Timothy C (Timothy)
James Y Knight wrote: Of course you can already do similar with current python, it just can't be spelled as nicely, and the default traceback printer won't use the info: try: raise AError except: newException = BError() newException.cause=sys.exc_info() raise newException

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

2005-05-10 Thread Delaney, Timothy C (Timothy)
Greg Ewing wrote: Nick Coghlan wrote: Hmm, with that approach, a code inspection tool like pychecker could be used to pick up the slack, and flag generators which have a yield inside a try/finally or a user defined statement without applying the needs finalisation decorator What about

Re: [Python-Dev] PEP 340 - For loop cleanup, and feature separation

2005-05-05 Thread Delaney, Timothy C (Timothy)
Greg Ewing wrote: I'm still bothered by the idea of for-loops not participating in the new generator finalization protocol. I agree - that's always been nagging at me too. The problem with it is that then you either: 1. Have a guarantee that an iterator will be exhausted when the for loop

Re: [Python-Dev] PEP 340 -- concept clarification

2005-05-04 Thread Delaney, Timothy C (Timothy)
Nick Coghlan wrote: Ah, someone else did post this idea first :) I knew I was standing on the shoulders of others :) To deal with the generator issue, one option would be to follow up on Phillip's idea of a decorator to convert a generator (or perhaps any standard iterator) into a block

Re: [Python-Dev] PEP 340 -- concept clarification

2005-05-03 Thread Delaney, Timothy C (Timothy)
Guido van Rossum wrote: I'd like the block statement to be defined exclusively in terms of __exit__() though. This does actually suggest something to me (note - just a thought - no real idea if it's got any merit). Are there any use cases proposed for the block-statement (excluding the

Re: [Python-Dev] PEP 340 -- concept clarification

2005-05-03 Thread Delaney, Timothy C (Timothy)
Delaney, Timothy C (Timothy) wrote: Guido van Rossum wrote: I'd like the block statement to be defined exclusively in terms of __exit__() though. 1. If an iterator declares __exit__, it cannot be used in a for-loop. For-loops do not guarantee resource cleanup. 2. If an iterator

Re: [Python-Dev] PEP 340 -- loose ends

2005-05-02 Thread Delaney, Timothy C (Timothy)
Phillip J. Eby wrote: Specifically, I propose that PEP 340 *not* allow the use of normal iterators. Instead, the __next__ and __exit__ methods would be an unrelated protocol. This would eliminate the need for a 'next()' builtin, and avoid any confusion between today's iterators and a

Re: [Python-Dev] PEP 340 -- loose ends

2005-05-02 Thread Delaney, Timothy C (Timothy)
Guido van Rossum wrote: Oops. Read the most recent version of the PEP again. __next__() doesn't take an exception argument, it only takes a value. Maybe this removes your concern? Actually, I misinterpreted it, assuming that the value passed in was an exception instance because the previous

RE: [Python-Dev] @decoration of classes

2005-03-30 Thread Delaney, Timothy C (Timothy)
Nick Coghlan wrote: # A decorator that does not alter its argument def register(callable): # Register the callable somewhere ... return callable # Decorated factory function @register def factory(): pass # Post-decorated class class factory:

RE: [Python-Dev] LinkedHashSet/LinkedHashMap equivalents

2005-03-09 Thread Delaney, Timothy C (Timothy)
Jeff Bauer wrote: I'm not specifically lobbying for its inclusion in stdlib, but I often find an ordered dict useful when I want both ordered and random access, e.g. situations: - database table fields/attributes - drop down field selectors Yep - these are also cases that are

RE: [Python-Dev] LinkedHashSet/LinkedHashMap equivalents

2005-03-09 Thread Delaney, Timothy C (Timothy)
Steven Bethard wrote: def filterdups(iterable): seen = set() for item in iterable: if item not in seen: seen.add(item) yield item Adding this to, say, itertools would cover all my use cases. And as long as you don't have too many duplicates,

RE: [Python-Dev] LinkedHashSet/LinkedHashMap equivalents

2005-03-08 Thread Delaney, Timothy C (Timothy)
Greg Ward wrote: I'll attach another approach to the same problem, an ordered dictionary object. I believe the semantics of adding/readding/deleting keys is the same as java.util.LinkedHashMap -- certainly it seems the most sensible and easy-to-implement semantics. That's essentially the

RE: [Python-Dev] Getting rid of unbound methods: patch available

2005-01-17 Thread Delaney, Timothy C (Timothy)
Guido van Rossum wrote: Keeping im_class would be tricky -- the information isn't easily available when the function is defined, and adding it would require changing unrelated code that the patch so far didn't have to get near. Also, it would not be compatible -- the unbound method sets

RE: [Python-Dev] Re: super() harmful?

2005-01-06 Thread Delaney, Timothy C (Timothy)
Guido van Rossum wrote: and the cumbersome way in which you have to invoke super. Given Python's dynamic nature I couldn't think of a way to make it less cumbersome. I see you tried (see below) and couldn't either. At this point I tend to say put up or shut up. Well, there's my autosuper

[Python-Dev] Out-of-date FAQs

2005-01-03 Thread Delaney, Timothy C (Timothy)
While grabbing the link to the copyright restrictions FAQ (for someone on python-list) I noticed a few out-of-date FAQ entries - specifically, most stable version and Why doesn't list.sort() return the sorted list?. Bug reports have been submitted (and acted on - Raymond, you work too fast ;) I

RE: [Python-Dev] MinGW And The other Py2.4 issue

2004-12-14 Thread Delaney, Timothy C (Timothy)
Martin v. Löwis wrote: Not at all. I'm talking about the release process, and prerequisites required in that process. This is worth mentioning because the list of prerequisites you need to perform a Python release is already quite long: Ah - sorry - misinterpreted. What is the size of the

RE: [Python-Dev] Re: The Other Py2.4 issue?

2004-12-12 Thread Delaney, Timothy C (Timothy)
Adam Bark wrote: Now this might sound a bit stupid but I've only been programming in python for about 6 months and before that about the same on VB. Anyway here goes, as python is built in C C++ surely every piece of python code has a corresponding piece of C/C++ albeit more complex. So