[py-svn] r7961 - in py/dist/py/builtin: . testing

hpk at codespeak.net hpk at codespeak.net
Wed Dec 22 10:23:01 CET 2004


Author: hpk
Date: Wed Dec 22 10:23:01 2004
New Revision: 7961

Added:
   py/dist/py/builtin/   (props changed)
   py/dist/py/builtin/__init__.py   (contents, props changed)
   py/dist/py/builtin/enumerate.py   (contents, props changed)
   py/dist/py/builtin/testing/
Log:
this is the start of cross-python-version
support for certain builtins.  Currently only 
enumerate, but basically this is the place 
where you can "backport" python2.4 and python2.3 
builtins to run on python2.2.  E.g. just use 

    py.builtin.enumerate(...) 

and your programm will run on python2.2 as well. 
or do 
    
    from py.builtin import enumerate 

or 

    from py.builtin import * 

some backporting help welcome ... 

If there are serious counter arguments i'd like 
to hear ... 



Added: py/dist/py/builtin/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/builtin/__init__.py	Wed Dec 22 10:23:01 2004
@@ -0,0 +1 @@
+#

Added: py/dist/py/builtin/enumerate.py
==============================================================================
--- (empty file)
+++ py/dist/py/builtin/enumerate.py	Wed Dec 22 10:23:01 2004
@@ -0,0 +1,9 @@
+from __future__ import generators 
+try:
+    enumerate = enumerate
+except NameError: 
+    def enumerate(iterable): 
+        i = 0 
+        for x in iterable: 
+            yield i, x
+            i += 1



More information about the pytest-commit mailing list