Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Zachary Ware
On Mon, Mar 17, 2014 at 10:31 AM, Mark Summerfield wrote: > 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

Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Mark Summerfield
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): > >

Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Oscar Benjamin
On 17 March 2014 08:44, 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.executa

Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Ben Finney
Devin Jeanpierre writes: > On Mon, Mar 17, 2014 at 2:02 AM, Ben Finney > wrote: > > Mark Summerfield writes: > > if getattr(sys, "frozen"):# ‘getattr’ will return None by default > > No it won't. > […] > Sure, but sys.executable always exists. My apologies for posting untested code wi

Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Devin Jeanpierre
On Mon, Mar 17, 2014 at 2:02 AM, Ben Finney wrote: > Mark Summerfield writes: > if getattr(sys, "frozen"):# ‘getattr’ will return None by default No it won't. > Lastly, it's slightly more Pythonic to execute the normal path > unconditionally, and let it raise an exception if there's a p

Re: Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Ben Finney
Mark Summerfield writes: > What is the correct idiom for getting the path to a top-level module I'm not sure I understand what this concept is. What do you mean by “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, "fr

Correct idiom for determining path when frozen in 3.4

2014-03-17 Thread Mark Summerfield
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!