Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57792

Re: How to find where data files are installed for my Python program

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'subject:Python': 0.06; '64-bit': 0.07; 'dynamically': 0.07; 'impacts': 0.07; 'reason,': 0.07; 'suppose': 0.07; 'aliases': 0.09; 'ascii': 0.09; 'bash': 0.09; 'broke': 0.09; 'difference,': 0.09; 'executable': 0.09; 'lawrence': 0.09; 'scripts,': 0.09; 'skip:/ 10': 0.09; 'subject:files': 0.09; 'wrapper': 0.09; 'subject:How': 0.10; 'python': 0.11; "wouldn't": 0.14; 'windows': 0.15; 'binary,': 0.16; 'command.': 0.16; 'command:': 0.16; 'different,': 0.16; 'elf': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'happily': 0.16; 'magic': 0.16; 'sake,': 0.16; 'script,': 0.16; 'script?': 0.16; 'sign,': 0.16; 'subject:program': 0.16; 'subject:where': 0.16; 'unix,': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'library': 0.18; 'obviously': 0.18; 'trying': 0.19; '(where': 0.19; 'starts': 0.20; 'code,': 0.22; 'shell': 0.22; 'install': 0.23; 'adds': 0.24; 'interpret': 0.24; 'parse': 0.24; "shouldn't": 0.24; 'mon,': 0.24; 'regardless': 0.24; 'source': 0.25; 'compiled': 0.26; 'defined': 0.27; 'skip:" 20': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'external': 0.29; 'am,': 0.29; '(like': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '(maybe': 0.31; 'dropped': 0.31; 'file': 0.32; 'figure': 0.32; 'another': 0.32; 'text': 0.33; 'running': 0.33; 'screen': 0.34; 'maybe': 0.34; 'could': 0.34; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'really': 0.36; 'executing': 0.36; 'subject:data': 0.36; 'done': 0.36; 'operating': 0.37; 'easiest': 0.38; 'ends': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'above,': 0.60; 'most': 0.60; 'course': 0.61; "you're": 0.61; 'such': 0.63; 'linked': 0.65; 'between': 0.67; 'prompt': 0.68; 'respect': 0.70; 'dollar': 0.74; 'programs,': 0.74; 'commands.': 0.84; 'distinguish': 0.84; 'execution.': 0.84; 'subject:find': 0.84; 'together,': 0.84; 'care,': 0.91; 'drops': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=2LpdETA9FiPw86sqTcpECelBqEB3OlWgdwBqKTbpwvQ=; b=0XAXKHVdnzSDBhtE/4PnpOhfKAWsJsIeIPCrdWxbCMuNiLopn7fR0617fg25kJ/28z 6OEhtHo6HDl8fpZooZNKbs4w3zqKI2JGUH0ru4bEg87ngrUsmSOVD/pj8NMuq9aPBpHg pLNBoRLPVQk/RKHwnZYilfl48bwGedd4TZHyQoeLFxD2zP759f6bVdY4VbsZKLJN3p2p uos96uFH4bQCGrE/PWVZlLfvBMBtPI8HBXi6fTlWKAFKugGMehOp1MczqvM15N1n6UFk w1obONpmWVmpzfw3XW0SPt0ZjBqO2Rq0/lrWJkS71SGv2KhkULKvQM7aCMlsN5w73tvj 8HOg==
MIME-Version 1.0
X-Received by 10.68.194.69 with SMTP id hu5mr732134pbc.170.1382943101857; Sun, 27 Oct 2013 23:51:41 -0700 (PDT)
In-Reply-To <l4kbe4$na4$1@ger.gmane.org>
References <00704f33-7e7f-4ccf-b28b-69776d2e237d@googlegroups.com> <526C7FEF.7020206@islandtraining.com> <CAPTjJmqVz8PidbbjXbSn=6M42m=LZg3JBh1mKQr7-FuiqzbOUQ@mail.gmail.com> <mailman.1637.1382848122.18130.python-list@python.org> <bd3ve5F6cjjU1@mid.individual.net> <CALwzidkXgAkkmE=Z=oxAXppUcKnudSQU9VcdFMRo26PEjmoXjg@mail.gmail.com> <7w7gcy9tpk.fsf@benfinney.id.au> <CAPTjJmp_npLE7xGPXPib16dTqomULRv8xOVuPGizruomnjUX3g@mail.gmail.com> <l4kbe4$na4$1@ger.gmane.org>
Date Mon, 28 Oct 2013 17:51:41 +1100
Subject Re: How to find where data files are installed for my Python program
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.1678.1382943105.18130.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382943105 news.xs4all.nl 15929 [2001:888:2000:d::a6]:42141
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57792

Show key headers only | View raw


On Mon, Oct 28, 2013 at 11:34 AM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> "What is the difference between "script" code (like Javascript and visual)
> made for the screen (where such magic values are utilized) and compiled
> source (made for the machine)?"
>
> This obviously impacts on the discussion above, so how does Unix, Windows
> and other operating systems distinguish these with respect to binary,
> executable, code library or whatever?

Suppose you pull up a shell - for argument's sake, let's say it's
Debian GNU/Linux and you're running bash. You get a prompt that ends
with a dollar sign, and you type "ls". What's going to get executed?

* An alias? You might have an internal function defined in your
.bashrc, or maybe a wrapper that adds parameters to your command.

* A bash internal command? The shell might directly interpret what you
specified. (I don't think ls is like that, but time is, on my
systems.)

* An external binary? On my systems, /bin/ls is an executable binary,
compiled and ready to run.

* A script? Another alternative to the shell alias, you could have
/usr/local/bin/ls that does something different, then maybe drops
through to /bin/ls. If it starts with "#!/usr/bin/python", it'll get
dropped through to Python for execution.

Chances are you wouldn't know the difference, as a human executing the
commands. And you shouldn't need to care, except in really weird
circumstances (maybe you broke your Python install and need to type
"/bin/ls" to figure out what's going on).

Most programs, trying to execute code, won't care about the difference
between binaries and scripts, though of course exec*() won't parse
bash aliases or internals. But if you need to distinguish for whatever
reason, the easiest way is to look at the magic numbers, which can be
done with the 'file' command:

rosuav@sikorsky:~$ file `which ls`
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.26,
BuildID[sha1]=0x55f1e005df252708d4c456dcc2c7dccea1006553, stripped

rosuav@sikorsky:~$ file `which zcat`
/bin/zcat: Bourne-Again shell script, ASCII text executable

Executables happily together, regardless of type.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Function for the path of the script? Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-26 19:23 -0700
  Re: Function for the path of the script? Skip Montanaro <skip.montanaro@gmail.com> - 2013-10-26 21:42 -0500
  Re: Function for the path of the script? Gary Herron <gary.herron@islandtraining.com> - 2013-10-26 19:52 -0700
  Re: Function for the path of the script? Chris Angelico <rosuav@gmail.com> - 2013-10-27 14:01 +1100
    Re: Function for the path of the script? Grant Edwards <invalid@invalid.invalid> - 2013-10-28 14:49 +0000
      Re: Function for the path of the script? Chris Angelico <rosuav@gmail.com> - 2013-10-29 01:59 +1100
      Re: Function for the path of the script? rurpy@yahoo.com - 2013-10-28 21:00 -0700
        Re: Function for the path of the script? Steven D'Aprano <steve@pearwood.info> - 2013-10-29 05:27 +0000
          Re: Function for the path of the script? Grant Edwards <invalid@invalid.invalid> - 2013-10-29 14:31 +0000
  Re: Function for the path of the script? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-27 03:42 +0000
  Re: Function for the path of the script? Ben Finney <ben+python@benfinney.id.au> - 2013-10-27 15:10 +1100
    Re: Function for the path of the script? Roy Smith <roy@panix.com> - 2013-10-27 09:38 -0400
    Re: Function for the path of the script? Grant Edwards <invalid@invalid.invalid> - 2013-10-28 14:58 +0000
      Re: Function for the path of the script? Ben Finney <ben+python@benfinney.id.au> - 2013-10-29 09:50 +1100
        Re: Function for the path of the script? Grant Edwards <invalid@invalid.invalid> - 2013-10-29 14:26 +0000
  How to find where data files are installed for my Python program (was: Function for the path of the script?) Ben Finney <ben+python@benfinney.id.au> - 2013-10-27 15:28 +1100
    Re: How to find where data files are installed for my Python program (was: Function for the path of the script?) rurpy@yahoo.com - 2013-10-26 22:18 -0700
    Re: How to find where data files are installed for my Python program Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-10-27 20:58 +1300
      Re: How to find where data files are installed for my Python program Ian Kelly <ian.g.kelly@gmail.com> - 2013-10-27 09:50 -0600
      Re: How to find where data files are installed for my Python program Ben Finney <ben+python@benfinney.id.au> - 2013-10-28 10:13 +1100
      Re: How to find where data files are installed for my Python program Ben Finney <ben+python@benfinney.id.au> - 2013-10-28 10:31 +1100
      Re: How to find where data files are installed for my Python program Chris Angelico <rosuav@gmail.com> - 2013-10-28 10:58 +1100
      Re: How to find where data files are installed for my Python program Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-28 00:34 +0000
      Re: How to find where data files are installed for my Python program Chris Angelico <rosuav@gmail.com> - 2013-10-28 17:51 +1100
        Re: How to find where data files are installed for my Python program Roy Smith <roy@panix.com> - 2013-10-28 08:51 -0400
          Re: How to find where data files are installed for my Python program Chris Angelico <rosuav@gmail.com> - 2013-10-29 00:06 +1100
  Re: How to find where data files are installed for my Python program (was: Function for the path of the script?) Chris Angelico <rosuav@gmail.com> - 2013-10-27 16:49 +1100
  Re: Function for the path of the script? Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-28 15:57 -0700
  Re: Function for the path of the script? Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-10-28 22:56 -0700

csiph-web