Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.039 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'else:': 0.03; 'cc:addr :python-list': 0.11; 'cc:name:python list': 0.16; 'false):': 0.16; 'getattr(sys,': 0.16; 'subject:when': 0.16; 'top-level': 0.16; 'wrote:': 0.18; 'module': 0.19; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply- To:1': 0.27; 'correct': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'getting': 0.31; 'url:python': 0.33; 'moment': 0.34; 'received:google.com': 0.35; 'hi,': 0.36; 'url:org': 0.36; 'skip:o 20': 0.38; 'url:library': 0.38; 'does': 0.39; 'skip:o 30': 0.61; 'march': 0.61; 'url:3': 0.61; '3.4': 0.84; 'idiom': 0.84; 'oscar': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=faQUzf74MSWM6YnoVDEwIlFZ8XqSN3eU0/D7qwgqGSg=; b=QQEorLPanv62+ufyRaIfaHNydDVsn/FxgImN5Q8X5XQAU8eIeTNwFt5uiurh5W3eiN j+jKV1lo0E1NBHURl4X0PGcIAh+eogJpmdgXKjUvGdLItPgxPZh+VBmroLQadLfzopMs G5jZnRm7mrT1pOjbNxsugGnjsevL8/+EntpGp/NdYiBdVEbqT6Azd3/eICChENeyIlBx Vqoabx443UE14pdlMy9usLY1uLO0JEN5Vy+NMbnzOPNdgFHshG8A9NyH54NkmD457DcG DRJZf1kdjRvNJEFc3DmyfVIB1e2D3fhdfVEdYG5nx145gkyafmjDc6J4BVN/HwtNXpn0 tIvg== X-Received: by 10.58.178.238 with SMTP id db14mr386538vec.25.1395049995649; Mon, 17 Mar 2014 02:53:15 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <8a0ca549-7bce-4210-8f9e-3465a769fc3c@googlegroups.com> References: <8a0ca549-7bce-4210-8f9e-3465a769fc3c@googlegroups.com> From: Oscar Benjamin Date: Mon, 17 Mar 2014 09:52:55 +0000 Subject: Re: Correct idiom for determining path when frozen in 3.4 To: Mark Summerfield Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395050301 news.xs4all.nl 2889 [2001:888:2000:d::a6]:35591 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68418 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.executable) > else: > path = os.path.dirname(__file__) Why do you want to know this? Does pkgutil.get_data do what you want? http://docs.python.org/3.3/library/pkgutil.html#pkgutil.get_data Oscar