Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91598
| Date | 2015-06-01 08:57 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: Using Python instead of Bash |
| References | <bn7mmadupkolhvttkok4dbsa71b9j81gmj@4ax.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.251.1433113049.5151.python-list@python.org> (permalink) |
On 31May2015 11:05, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote: > 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)? (Yes, PIL is stale, Pillow is live.) Or, more direct if Pillow doesn't have what he wants, is to use the ImageMagick or GraphicsMagick Python libraries. Anything ImageMagick can do via the command line they should be able to do directly. The advantage of using PIL/Pillow or ImageMagick/GraphicsMagick within Python is that, memory permitting, one can avoid making (and therefore needing to clean up) temporary files. > 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). os.system passed a string to the shell. That has quoting/security issues. (Exactly like shell=True with subprocess.) With his specific example this isn't a big deal because all the filenames are benign etc, but as a general rule using subprocess and passing explicit command line argument strings is safer. All of which you know, I know. But good to get it said in the thread. Cheers, Cameron Simpson <cs@zip.com.au>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Using Python instead of Bash Cameron Simpson <cs@zip.com.au> - 2015-06-01 08:57 +1000
csiph-web