[Zope-Coders] Re: [Zope-Checkins] CVS: Zope/lib/python/DateTime/tests -testDateTime.py:1.12.6.3

Fred L. Drake, Jr. fdrake@acm.org
Thu, 17 Oct 2002 12:02:26 -0400


Andreas Jung writes:
 > The tests in StructuredText use the following code...also not bad ;-)
 > 
 > package_dir = os.path.split(ST.__file__)[0]
 > regressions=os.path.join(package_dir, 'regressions')

It's always cool to use a __file__ that's know to exist, but I'll
crtique this anyway.  ;-)

- ST.py is not in the same directory as the file that's using it, so
  it's __file__ doesn't point to the same directory as the script
  lives in.  This also *assumes* that the package containing ST has
  only a single entry in it's __path__, which is *usually* safe.

- os.path.dirname(...) would be easier to read than os.path.split(...)[0]


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation