
I really think the whole "lazy" idea is misguided. If it's possible for the interpreter to determine automatically when it needs to force evaluation of a lazy expression or statement, then why not make *all* expressions and statements lazy by default? I think it's pretty clear when to force evaluation: 1) when the result is used in a control flow statement/expression 2) when the result is output (file, network, or other I/O) and 3) evaluate all pending lazy code before releasing the GIL. At that point, why not make lazy evaluation an implicit feature of the language, like the garbage collector. On Wed, Mar 1, 2017 at 8:58 PM, Chris Barker <chris.barker@noaa.gov> wrote:
Going through machinations to satisfy PEP 8 makes no sense -- it's s style *guide* -- that's it.
-CHB
On Tue, Feb 28, 2017 at 3:31 PM, Nicolas Cellier < contact@nicolas-cellier.net> wrote:
I have seen some interest into lazy functionality implementation.
I wondered if it can be linked with optional import.
PEP 8 <http://www.python.org/dev/peps/pep-0008/> authoritatively states:
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
So, if we want to stick to PEP8 with non mandatory import, we have to catch the import errors, or jail the class or function using extra functionnality.
Why not using the potential lazy keyword to have a nice way to deal with it?
For example:
lazy import pylab as pl # do nothing for now
# do stuff
def plot(*args): pl.figure() # Will raise an ImportError at this point pl.plot(...)
That way, our library will raise an ImportError only on plot func usage with an explicit traceback : if matplotlib is not installed, we will have the line where it is used for the first time and we will have the name of the faulty library.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
--
Christopher Barker, Ph.D. Oceanographer
Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/