Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; '16,': 0.03; 'else:': 0.03; 'read.': 0.03; 'elif': 0.05; 'output': 0.05; 'subject:Python': 0.06; '(python,': 0.07; 'binary': 0.07; 'linux,': 0.07; 'perl,': 0.07; 'python3': 0.07; 'utf-8': 0.07; '%s"': 0.09; 'ascii': 0.09; 'descr': 0.09; 'file)': 0.09; 'skip:/ 10': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'changes': 0.15; '"python': 0.16; 'bash,': 0.16; 'binary.': 0.16; 'char,': 0.16; 'exceptions,': 0.16; 'fn)': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'half.': 0.16; 'non-ascii': 0.16; 'rough': 0.16; 'script,': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'library': 0.18; 'wed,': 0.18; 'bit': 0.19; 'file,': 0.19; 'meant': 0.20; 'import': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'text,': 0.24; 'text.': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'script': 0.25; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'primarily': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; "d'aprano": 0.31; 'etc.).': 0.31; 'os,': 0.31; 'safely': 0.31; 'steven': 0.31; 'file': 0.32; 'probably': 0.32; 'figure': 0.32; 'quite': 0.32; 'text': 0.33; 'becomes': 0.33; 'skip:# 10': 0.33; 'third': 0.33; 'actual': 0.34; 'except': 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'house,': 0.36; 'half': 0.37; 'system,': 0.38; 'convention': 0.38; 'filled': 0.38; 'files': 0.38; 'pm,': 0.38; "couldn't": 0.39; 'how': 0.40; 'most': 0.60; 'skip:o 30': 0.61; 'numbers': 0.61; 'high': 0.63; 'more': 0.64; 'jul': 0.74; 'assertion.': 0.84; 'to:none': 0.92 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:cc :content-type; bh=fggCTEKH6dr+/2+EnmOEGU09YYB5Drz6VhGuVoaE56s=; b=wllFqBiABKHHKl4742YL5z+zWarwsdOecT+NPiFGYz6fME7bMpIbpqkPVWLK9SR8AA dzmj6lElAF2DutOG5xViPpaSJp5CvZ92pLwMbrwv3IK4i0WXlVdBCR4HkIGeaajS0DKg ahF9/fHLzBgZazDIB+fo/itUCfdsjgyj52kbiUlBhUTY2521c1niMhYtJuU8YKBiBWP4 /5LdvjizQFLslNH6MTNbxRvYwl5FI5atRuczoj5JmLqEMPlxYbMVJs3s+PWj0F8ZOzJd 4bOnSKd6uNfSetV8thCLt2EaA5OEV+mEMzQe//DLgB+dEzOLsCXOnbSefxKsXWy8t5to i2PA== MIME-Version: 1.0 X-Received: by 10.220.195.67 with SMTP id eb3mr13410875vcb.30.1405515355054; Wed, 16 Jul 2014 05:55:55 -0700 (PDT) In-Reply-To: <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 16 Jul 2014 22:55:54 +1000 Subject: Re: Python 3 is killing Python From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 65 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1405515780 news.xs4all.nl 2971 [2001:888:2000:d::a6]:46214 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:74550 On Wed, Jul 16, 2014 at 10:10 PM, Steven D'Aprano wrote: > Linux, like all Unixes, is primarily a text-based platform. With a few > exceptions, /etc is filled with text files, not binary files, and half > the executables on the system are text (Python, Perl, bash, sh, awk, > etc.). An interesting assertion. I know "half" is not meant to be an actual estimate, but out of curiosity, I whipped up a quick script to figure out just how many of my executables are text and how many aren't. #!/usr/bin/env python3 import os, subprocess text = binary = unknown = unreadable = 0 for path in os.environ["PATH"].split(":"): for file in os.listdir(path): fn = os.path.join(path, file) try: t = subprocess.check_output(["file", "-L", fn]) except subprocess.CalledProcessError: print("Unreadable: %s" % fn) unreadable += 1 continue if isinstance(t, bytes): t = t.decode("ascii") # Now to try to figure out what's text and what's binary. if "text" in t: # Most Unixes follow the convention of having "text" in # the output of all files that can be safely blatted to # a terminal - for instance, "ASCII text executable" is # used to describe most shell scripts etc; this file is # a "Python script, ASCII text executable". If I put in # a non-ASCII char, the 'file' descr becomes changes to # "Python script, UTF-8 Unicode text executable". text += 1 elif "directory" in t: # Ignore directories. pass elif "LSB executable" in t or "LSB shared object" in t: binary += 1 else: print(t.strip()) unknown += 1 print("%d text, %d binary" % (text, binary)) if unknown: print("Also %d unknowns, which are probably binary." % unknown) if unreadable: print("Plus %d files that couldn't be read." % unreadable) On my system, it says: rosuav@sikorsky:~$ python3 exectypes.py /usr/local/bin/youtube-dl: data Unreadable: /usr/bin/wine-safe /usr/bin/mptopdf: LaTeX auxiliary file, /usr/bin/gvfs-less: Palm OS dynamic library data "#!/bin/sh" Unreadable: /usr/bin/gserialver 1140 text, 2060 binary Also 3 unknowns, which are probably binary. Plus 2 files that couldn't be read. So a bit more than a third of my executables are text. That's a pretty high proportion, and not very far off the rough guesstimate of half. (And I tried this on three other Linuxes I have around the house, getting broadly the same proportion, although the numbers are quite different.) ChrisA