From: Ype K. <yk...@xs...> - 2001-07-25 18:16:31
|
Finn, >[Ype Kingma] > >>I investigated the problem of my previous post (below). >>It appears that os.path.dirname() is confused when >>using both backward and forward slashes, ... > >Could you show an example of this confusion? I think the results is far >better than what I had feared: > >Jython 2.1a2 on java1.4.0-beta (JIT: null) >Type "copyright", "credits" or "license" for more information. >>>> import os >>>> os.path.dirname('e:\\someDir\\packag/modul.py') >'e:\\someDir\\packag' >>>> os.path.dirname('e:\\someDir\\packag\\modul.py') >'e:\\someDir\\packag' >>>> os.path.dirname('e:\\someDir/packag/modul.py') >'e:\\someDir\\packag' >>>> I'll give the answer in a day or two. I vaguely recall that output of your first example was 'e:\\someDir', but real output is better. <snip> > >>Finally another thing (21a1): I renamed the directory of a package, >>and then changed all occurrences of the package name. > >Then I found out that the compiled modules contain a reference > >to the old package file name, even though they where loaded > >using the new package name. The fix was to remove the class files. >>Should this be added to the docs or is it a bug? > >I suppose it depends on the situation. Note that CPython will write the >old packagename in stacktraces. Where is it you say the old package >names? Off the top of my head: It's in the __filename__ attribute of the imported compiled module: sys.modules['modul'].__filename__ Thanks, Ype |