[pywin32-bugs] [ pywin32-Patches-776836 ] genpy : _NewEnum for dynamic collections
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2003-07-24 09:40:26
|
Patches item #776836, was opened at 2003-07-24 09:40 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=776836&group_id=78018 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Marc ENGEL (marcengel) Assigned to: Nobody/Anonymous (nobody) Summary: genpy : _NewEnum for dynamic collections Initial Comment: In a previous thread on comp.lang.python a request was made to have _NewEnum called for each for blocks and not only once and then cached in the python proxy class generated by genpy: http://groups.google.com/groups?hl=fr&lr=&ie=UTF- 8&oe=UTF-8&threadm=8ecta7%24nn5%241% 40nnrp1.deja.com&rnum=1&prev=/groups%3Fhl%3Dfr% 26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26selm% 3D8ecta7%2524nn5%25241%2540nnrp1.deja.com Indeed the _NewEnum normally gives an iterator that iterates on a copy of the collection data. This is the desired behaviour when iterating on a for block but next time if the collection is updated, it is desired to iterate on the latest copy so we need to get a new iterator. I made a change in genpy to create the __iter__ method that is called each time an iterator is requested before the __getitem__ is called. I also added in win32com.client.util the WrapIter function with its associated class. It seems to work well for my collection. Hope it may help someone. The modified files are attached ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=776836&group_id=78018 |