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


Groups > comp.lang.python > #91585

Re: Using Python instead of Bash

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.python
Subject Re: Using Python instead of Bash
Organization Decebal Computing
References <87h9qsnckl.fsf@Equus.decebal.nl> <mailman.247.1433084763.5151.python-list@python.org>
Date 2015-05-31 19:06 +0200
Message-ID <87382cn0bj.fsf@Equus.decebal.nl> (permalink)

Show all headers | View raw


Op Sunday 31 May 2015 17:05 CEST schreef Dennis Lee Bieber:

> On Sun, 31 May 2015 14:42:02 +0200, Cecil Westerhof
> <Cecil@decebal.nl> 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:
>
> 	<code snipped>
>
> 	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.

That is true (the conversion). But there are two reasons for this.
- I want to get some experience with Python.
- I want to implement extra functionality, which would be easier with
Python as with Bash.

Also: I am thinking about using ipython3 instead of bash.


> 	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)?

That is something to look into. My experience with ImageMagick is very
good, but if Python could do an equal good job, then it would be good
to switch. That also removes a dependency.


> 	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).

I already use check_call.


By the way: because of the lpr my script only works on Linux (and
probably Unix and Apple). Can I rewrite it in such a way that it also
works with Windows? Someone else has to test it then, because I do not
have a Windows computer.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

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


Thread

Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 14:42 +0200
  Re: Using Python instead of Bash Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2015-05-31 16:02 +0200
    Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 18:36 +0200
  Re: Using Python instead of Bash Cem Karan <cfkaran2@gmail.com> - 2015-05-31 10:14 -0400
    Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 18:58 +0200
  Re: Using Python instead of Bash Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-05-31 11:05 -0400
    Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 19:06 +0200
      Re: Using Python instead of Bash Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-05-31 20:53 -0400
        Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 11:25 +0200
      Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 09:11 +0200
  Re: Using Python instead of Bash Ethan Furman <ethan@stoneleaf.us> - 2015-05-31 22:08 -0700
  Re: Using Python instead of Bash Larry Hudson <orgnut@yahoo.com> - 2015-06-01 00:56 -0700
    Re: Using Python instead of Bash Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-06-01 11:06 +0300
      Re: Using Python instead of Bash alister <alister.nospam.ware@ntlworld.com> - 2015-06-01 09:07 +0000
        Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 12:44 +0200
          Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 17:44 +0200
            Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 18:44 +0200
              Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 20:42 +0200
                Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 21:57 +0200
                Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 22:42 +0200
                Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 23:04 +0200
    Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 11:11 +0200
      Re: Using Python instead of Bash Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 12:38 +0300
  Re: Using Python instead of Bash Grant Edwards <invalid@invalid.invalid> - 2015-06-01 14:51 +0000

csiph-web