Steven D'Aprano wrote:

> What should I do when I can't rely on functions that 
> don't exist in older versions of Python?
> 
Ideally:

if 'iter' not in dir(__builtins__):
        import sys
        sys.exit('Archaic Python not supported, please upgrade')


Alternatively fill in the blanks with appropriate fallback code:

if 'iter' not in dir(__builtins__):
        def iter(obj):
           ... remainder of definition left as an exercise ...
     __builtins__.iter = iter

where iter does roughly what the iter builtin does.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to