Other situations like this (was RE: [Python-Dev] Nested scopes resolution -- you can breathe again!)

Guido van Rossum guido@digicool.com
Sat, 24 Feb 2001 11:44:54 -0500


> Right, I don't really want them in if/else blocks, you're right. Try/except
> would be nice, though.

Can't allow that.  See Tim's draft PEP; allowing tis makes the meaning
too muddy.

I suppose you want this because you think you may have code that wants
to use a new feature when it exists, but which should still work when
it doesn't.

The solution, given the constraints on the placement of the __future__
import, is to place the code that uses the new feature in a separate
module and have another separate module that does not use the new
feature; then a parent module can try to import the first one and if
that fails, import the second one.

But I bet that in most cases you'll be better off coding without
dependence on the new feature if your code needs to be backwards
compatible!

--Guido van Rossum (home page: http://www.python.org/~guido/)
> > Presumably all versions of Python after and including 2.1 will know
> > about __future__.  In those cases, the compiler will complain if
> > feature is no defined.  The complaint can be fairly specific:
> > "__future__ feature curly_braces is not defined."
> 
> Will this be a warning, or an error/exception ?

Error of course.

--Guido van Rossum (home page: http://www.python.org/~guido/)