On Monday, 17 March 2014 08:44:23 UTC, Mark Summerfield wrote: > Hi, > > > > What is the correct idiom for getting the path to a top-level module in 3.3 > and 3.4 when the module might be frozen? > > > > At the moment I'm using this: > > > > if getattr(sys, "frozen", False): > > path = os.path.dirname(sys.executable) > > else: > > path = os.path.dirname(__file__) > > > > Thanks!
My code was adapted from this: http://cx-freeze.readthedocs.org/en/latest/faq.html#using-data-files When you freeze a Python program with cx_Freeze, sys.freeze exists; but otherwise it doesn't. I develop some programs which I freeze for distribution but during development I test them as-is so I need to be able to distinguish. Also, from 3.4, __file__ won't exist in frozen modules: http://docs.python.org/3.4/whatsnew/3.4.html#changes-in-the-python-api Thanks for your thoughtful replies. -- https://mail.python.org/mailman/listinfo/python-list