`~/.pythonrc' `from __future__ import'
Michael Hudson
mwh at python.net
Mon Jul 8 09:21:40 EDT 2002
pinard at iro.umontreal.ca (François Pinard) writes:
> Suppose, for example, that I write a module in which some function makes
> good use of some future feature (it could be the `yield, statement),
> but I want to provide an alternate implementation of that function which
> is less interesting (because it gets much complex and slower) in case the
> feature is not available. Since I cannot except out of the `from __future__
> import' statement, for reasons I understand, I do not see how I take good
> advantage of available future features, in a program meant to be portable
> between versions. Maybe the future statement is rougher than I expected?
I think you more-or-less have to have separate modules for the
differently versioned functionality, eg.
try:
from two_point_two_using_module import func
except SyntaxError: # is that what bogus future statements should
# really raise? too late now, I guess
from two_point_one_using_module import func
...
Writing code that uses 2.2 features where possible but still runs on
2.1 is a pain, but I'm not sure how it could have been done better,
really.
Cheers,
M.
--
I have a feeling that any simple problem can be made arbitrarily
difficult by imposing a suitably heavy administrative process
around the development. -- Joe Armstrong, comp.lang.functional
More information about the Python-list
mailing list