On Mon, Mar 17, 2014 at 2:02 AM, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> Mark Summerfield <l...@qtrac.plus.com> 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 problem::
>
>     try:
>         executable = sys.executable
>     except AttributeError:
>         executable = __file__
>     path = os.path.dirname(executable)

Sure, but sys.executable always exists. sys.frozen doesn't, and the
existence or nonexistence is apparently meaningful; so your code does
something different than the original problem statement.

Also, if that weren't the case, I'd really replace that try-except
with getattr(sys, 'executable', __file__)

-- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to