Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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; 'subject:Python': 0.05; 'preference': 0.05; 'sufficient': 0.05; 'think,': 0.05; 'bash': 0.07; 'other)': 0.09; 'pil': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'python.': 0.11; 'ignore': 0.14; '(heck,': 0.16; '>to': 0.16; 'bash,': 0.16; 'bigger.': 0.16; 'instead).': 0.16; 'message-id:@4ax.com': 0.16; 'processes.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subprocess': 0.16; 'sufficient,': 0.16; 'url:home': 0.18; 'shell': 0.18; 'library': 0.20; '(or': 0.21; 'simpler': 0.22; 'try:': 0.22; '2015': 0.23; 'passing': 0.23; 'seems': 0.24; 'script': 0.25; 'example': 0.25; 'idea': 0.26; 'header:X -Complaints-To:1': 0.26; 'external': 0.27; '+0200,': 0.27; 'command': 0.28; 'actual': 0.29; 'queue': 0.29; 'terminating': 0.29; 'convert': 0.29; 'print': 0.31; "i'd": 0.31; 'creating': 0.32; 'implement': 0.32; 'probably': 0.32; 'impression': 0.33; 'running': 0.34; "i'll": 0.34; 'could': 0.35; 'to:addr:python- list': 0.35; 'submitting': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'thought': 0.37; 'instead': 0.38; 'received:org': 0.38; 'someone': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'real': 0.61; 'waiting': 0.63; 'between': 0.65; 'jobs': 0.67; 'cecil': 0.84; 'subject:Using': 0.84; 'westerhof': 0.84; 'dennis': 0.91; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Using Python instead of Bash Date: Sun, 31 May 2015 11:05:55 -0400 Organization: IISS Elusive Unicorn References: <87h9qsnckl.fsf@Equus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-221-244.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433084763 news.xs4all.nl 2903 [2001:888:2000:d::a6]:42008 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91579 On Sun, 31 May 2015 14:42:02 +0200, Cecil Westerhof declaimed the following: >I help someone that has problems reading. For this I take photo's of >text, use convert from ImageMagick to make a good contrast (original >paper is grey) and use lpr to print it a little bigger. > >Normally I would implement this in Bash, but I thought it a good idea >to implement it in Python. This is my first try: My first impression is that all you did was convert BASH line for line to Python -- and are still passing all the real work over to external programs ("convert" and "lpr"), using subprocess... Instead of a BASH script alternating between running command line utilities convert and lpr, you have a BASH (or other) shell running a Python process and Python alternating between a pair of command line utilities with all the overhead of creating and terminating processes. I'll concede submitting jobs to a print queue probably does work easier this way, but I'd have to ask if the "convert" could be performed using actual Python -- the old Python Imaging Library -- PIL -- for example (superseded, I think, by pillow)? Given that you do nothing between creating a subprocess and waiting for it to exit, subprocess.Popen() could be overkill -- the simpler subprocess.call() could be sufficient (heck, the old os.system() is sufficient, but preference seems to be to ignore it for subprocess.call() instead). -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/