<div dir="ltr">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.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 1, 2017 at 8:58 PM, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Going through machinations to satisfy PEP 8 makes no sense -- it's s style *guide* -- that's it.<br><br></div>-CHB<br><br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Feb 28, 2017 at 3:31 PM, Nicolas Cellier <span dir="ltr"><<a href="mailto:contact@nicolas-cellier.net" target="_blank">contact@nicolas-cellier.net</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div>I have seen some interest into lazy functionality implementation.<br><br></div>I wondered if it can be linked with optional import.<br><div class="m_3912223572365872725m_-7748567276886954481gmail-m_-2113992186940316494gmail-post-text">
<p><a href="http://www.python.org/dev/peps/pep-0008/" rel="noreferrer" target="_blank">PEP 8</a> authoritatively states:</p>

<blockquote><div>
  <p>Imports are always put at the top of
  the file, just after any module
        comments and docstrings, and before module globals and constants.</p></div></blockquote>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.<br><br></div><div class="m_3912223572365872725m_-7748567276886954481gmail-m_-2113992186940316494gmail-post-text">Why not using the potential lazy keyword to have a nice way to deal with it?<br><br></div><div class="m_3912223572365872725m_-7748567276886954481gmail-m_-2113992186940316494gmail-post-text">For example:<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>lazy import pylab as pl  # do nothing for now<br><br></div><div># do stuff<br><br></div><div>def plot(*args):<br></div><div>    pl.figure() # Will raise an ImportError at this point<br></div><div>    pl.plot(...)<br></div></blockquote><div><br></div><div>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.<br></div></div>
<br></div></div><span class="">______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><br>-- <br><div class="m_3912223572365872725gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            <a href="tel:(206)%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a>   voice<br>7600 Sand Point Way NE   <a href="tel:(206)%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a>   fax<br>Seattle, WA  98115       <a href="tel:(206)%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a>   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br></blockquote></div><br></div>