Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68417
| 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 | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.014 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'exists.': 0.07; 'executable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sure,': 0.09; 'try:': 0.09; 'behaviour.': 0.16; 'believes': 0.16; 'clear.': 0.16; 'exponential': 0.16; 'finite': 0.16; 'finney': 0.16; 'getattr(sys,': 0.16; 'pythonic': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement.': 0.16; 'subject:when': 0.16; 'substitute': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'header:User- Agent:1': 0.23; 'helpful': 0.24; 'mon,': 0.24; 'right.': 0.26; 'header:X-Complaints-To:1': 0.27; 'am,': 0.29; 'raise': 0.29; "doesn't": 0.30; 'code': 0.31; 'posting': 0.31; 'apparently': 0.31; 'existence': 0.31; 'values.': 0.31; 'writes:': 0.31; 'probably': 0.32; 'problem': 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'picking': 0.36; "didn't": 0.36; 'thanks': 0.36; 'skip:o 20': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; '8bit%:29': 0.60; 'hope': 0.61; 'making': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'different': 0.65; 'skip:\xe2 10': 0.65; 'world': 0.66; 'mar': 0.68; 'default': 0.69; 'led': 0.72; '8bit%:43': 0.74; '8bit%:46': 0.78; '2:02': 0.84; 'lastly,': 0.84; 'mistakes.': 0.84; 'received:125': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ben Finney <ben+python@benfinney.id.au> |
| Subject | Re: Correct idiom for determining path when frozen in 3.4 |
| Date | Mon, 17 Mar 2014 20:23:59 +1100 |
| References | <8a0ca549-7bce-4210-8f9e-3465a769fc3c@googlegroups.com> <85ha6xp59k.fsf@benfinney.id.au> <CABicbJK9tyNoiPMKZdLqYoebrsWXPet7YxWPUo4s7_j9P7NBkg@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xBD41714B |
| X-Public-Key-Fingerprint | 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-gpg.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) |
| Cancel-Lock | sha1:RGS34Yib3PhzkgKxJcYg33SXBmU= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8182.1395048251.18130.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1395048251 news.xs4all.nl 2862 [2001:888:2000:d::a6]:58647 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:68417 |
Show key headers only | View raw
Devin Jeanpierre <jeanpierreda@gmail.com> writes: > On Mon, Mar 17, 2014 at 2:02 AM, Ben Finney <ben+python@benfinney.id.au> wrote: > > Mark Summerfield <list@qtrac.plus.com> 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 without making that clear. Thanks to Devin for picking up my mistakes. > > Lastly, it's slightly more Pythonic to execute the normal path > > unconditionally, and let it raise an exception if there's a problem:: > > > > try: > > executable = sys.executable > > except AttributeError: > > executable = __file__ > > path = os.path.dirname(executable) > sys.frozen doesn't [necessarily exist], and the existence or > nonexistence is apparently meaningful; so your code does something > different than the original problem statement. Right. I didn't understand why ‘__file__’ is a suitable substitute for ‘sys.executable’; they're always (?) different values. So that probably is what led to the confusion in the code behaviour. I hope the Pythonic idioms are helpful to the original poster nevertheless. -- \ “Anyone who believes exponential growth can go on forever in a | `\ finite world is either a madman or an economist.” —Kenneth | _o__) Boulding | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Correct idiom for determining path when frozen in 3.4 Mark Summerfield <list@qtrac.plus.com> - 2014-03-17 01:44 -0700
Re: Correct idiom for determining path when frozen in 3.4 Ben Finney <ben+python@benfinney.id.au> - 2014-03-17 20:02 +1100
Re: Correct idiom for determining path when frozen in 3.4 Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-03-17 02:16 -0700
Re: Correct idiom for determining path when frozen in 3.4 Ben Finney <ben+python@benfinney.id.au> - 2014-03-17 20:23 +1100
Re: Correct idiom for determining path when frozen in 3.4 Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-03-17 09:52 +0000
Re: Correct idiom for determining path when frozen in 3.4 Mark Summerfield <list@qtrac.plus.com> - 2014-03-17 08:31 -0700
Re: Correct idiom for determining path when frozen in 3.4 Zachary Ware <zachary.ware+pylist@gmail.com> - 2014-03-17 11:03 -0500
csiph-web