[Tutor] code works in windows command but not ubuntu terminal

Danny Yoo dyoo at hashcollision.org
Fri Jan 24 23:26:30 CET 2014


> Ah! I was just running into this... I did not know that. So there's no
> way to get it to search a path (other than coding some string
> concatenation of path names or something, of course) to open a file?

Potentially distutils.spawn.find_executable might apply,

    http://docs.python.org/2/distutils/apiref.html#module-distutils.spawn

but this it is not intended for finding data files either.


If you really need something like this, you'll probably be writing
your own path searching routines for this, as to my knowledge this is
not provided by the standard library.

(Probably for a good reason: sometimes searching for a data resource
without knowing exactly where it should be can be a susceptible vector
for attacks.  That is, you might consider this a convenience vs.
safety thing.  Directory search can be _expensive_ in certain contexts
as well, such as on a networked file system, for example.)

---

In a professional context: there are libraries in place where you say
explicitly which resources your file depends on at installation time,
and the library manages the placement and finding of those resources
at runtime.  For an example, see the distutils.package_data option:

    http://docs.python.org/2/distutils/setupscript.html#installing-package-data


More information about the Tutor mailing list