<div dir="ltr">Ryan I assume any error could be translated to your version through the `from ` statement too?<div><br></div><div>Regarding the rabbit hole, the internet connection and privileges were required for running this script in the first place. I only suggest giving the developer - perhaps not a software engineer at all - an easy way not to require the (possibly inexperienced) user to do it manually.</div><div><br></div><div>Put it another way, you a copy-pasted code from SO is not needed to use only stdlib now.</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Sep 19, 2016 at 8:34 PM Ryan Gonzalez <<a href="mailto:rymg19@gmail.com">rymg19@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">This sounds like a great idea, but I've seen stuff like this done before, and it never ends well. You end up with a gargantuan-sized rabbit hole, since running a basic script could now involve using an internet connection and potentially root permissions.</p>
<p dir="ltr">IF one were to go this route, I prefer bundling a `requirements.txt` into the distribution and then doing something like this in the script:<br></p>
<p dir="ltr">import pkgcheck<br>
pkgcheck.check_requirements('requirements.txt')<br></p>
<p dir="ltr">If any of the requirements were missing, then something like this would happen:<br></p>
<p dir="ltr">Traceback (most recent call last):<br>
...<br>
MissingPackageError: This script requires package(s) which are not installed: mypackage>=1.0, other_package<br></p>
<p dir="ltr">That way, you don't get the weird import errors, but you don't have to worry about all the subtleties of automatic downloading.</p>
<p dir="ltr">--<br>
Ryan<br>
[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.<br>
<a href="http://kirbyfan64.github.io/" target="_blank">http://kirbyfan64.github.io/</a></p>
<div class="gmail_quote"></div><div class="gmail_quote">On Sep 19, 2016 11:26 AM, "אלעזר" <<a href="mailto:elazarg@gmail.com" target="_blank">elazarg@gmail.com</a>> wrote:<br type="attribution"></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Many proposals to add something to stdlib are rejected here with the suggestion to add such library to pypi first. As noted by someone, pypi is not as reachable as stdlib, and one should install that package first, which many people don't know how. Additionally, there is no natural distinction between 3rd party dependencies and in-project imports (at least in tiny projects).<div><br></div><div>This can be made easier if the first line of the program will declare the required library, and executing it will try to download and install that library if it is not installed yet. Additionally, the 3rd party dependencies will be more explicit, and editors can then allow you to search for them as you type.<div><br></div><div>Of course it is *not* an alternative for real dependency management, but it will ease the burden on small scripts and tiny projects - which today simply break with errors that many users does not understand, instead of simply asking permission to install the dependency.</div><div><br></div><div>Elazar</div></div></div>
<br></blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">_______________________________________________<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/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div></blockquote></div>