Re: Opinion on best practice...

2013-02-08 Thread John Ladasky
On Tuesday, February 5, 2013 5:55:50 PM UTC-8, Steven D'Aprano wrote: > To do anything meaningful in bash, you need to be an expert on > passing work off to other programs... [snip] > If you took the Zen of Python, > and pretty much reversed everything, you might have the Zen of Bash: I have to

Re: Opinion on best practice...

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 5:29 AM, Dennis Lee Bieber wrote: > If you want the real nightmare -- look into the IBM "queue" scheme > (not many REXX implementations except on IBM mainframes support that). > One can push lines onto the queue, such that when the script exits, the > command proces

Re: Opinion on best practice...

2013-02-07 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > Line 3 has unquoted "echo" which is not a REXX command; it is > considered an external command and is passed the /result/ of calling > REXX time() -- where Windows executes it Good lord, that's even worse than I feared. So it's not just unparsable non-REXX code that is

Re: Opinion on best practice...

2013-02-07 Thread Steven D'Aprano
Chris Angelico wrote: > On Thu, Feb 7, 2013 at 5:50 PM, Steven D'Aprano > wrote: >> On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: >> >>> You misunderstand. It's actually a very simple rule. Python follows C's >>> principle of accepting that any return value from an expression should >

Re: Opinion on best practice...

2013-02-06 Thread Chris Angelico
On Thu, Feb 7, 2013 at 5:50 PM, Steven D'Aprano wrote: > On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: > >> You misunderstand. It's actually a very simple rule. Python follows C's >> principle of accepting that any return value from an expression should >> be ignored if you don't do an

Re: Opinion on best practice...

2013-02-06 Thread Steven D'Aprano
On Thu, 07 Feb 2013 16:28:17 +1100, Chris Angelico wrote: > On Thu, Feb 7, 2013 at 10:46 AM, Steven D'Aprano > wrote: >> Dennis Lee Bieber wrote: >>> Though that is the nice feature of REXX*... Anything that wasn't >>> parsable as a REXX statement was automatically sent to the current >>> command

Re: Opinion on best practice...

2013-02-06 Thread Chris Angelico
On Thu, Feb 7, 2013 at 10:46 AM, Steven D'Aprano wrote: > Dennis Lee Bieber wrote: >> Though that is the nice feature of REXX*... Anything that wasn't >> parsable as a REXX statement was automatically sent to the current >> command processor. > > Nice? Are you being sarcastic? What you're describi

Re: Opinion on best practice...

2013-02-06 Thread Steven D'Aprano
Dennis Lee Bieber wrote: > On Wed, 6 Feb 2013 17:16:04 +1100, Chris Angelico > declaimed the following in gmane.comp.python.general: > >> >> It feels silly enough translating this OS/2 batch script: >> >> @logon SOME_USER /pSOME_PASS /vl >> @e:\rexx\load >> @db2 start database manager >> @exit

Re: Opinion on best practice...

2013-02-06 Thread Grant Edwards
On 2013-02-06, Steven D'Aprano wrote: > Chris Angelico wrote: > >> Python is not an "excellent option". It's a bad fit for shell >> scripting, it just happens to be way better than a weak shell. Having >> grown up on command.com, I found OS/2's cmd.exe to be a massive >> improvement, and Windows's

Re: Opinion on best practice...

2013-02-06 Thread Grant Edwards
On 2013-02-06, Neil Cerutti wrote: > On 2013-02-05, Grant Edwards wrote: >> On 2013-02-05, Neil Cerutti wrote: >>> On 2013-02-05, Walter Hurry wrote: > Sorry, I'm a Linux guy. I have no clue what that means. Hooray for common sense! Python is great, but it's silly to use Pyt

Re: Opinion on best practice...

2013-02-06 Thread Grant Edwards
On 2013-02-06, Ian Kelly wrote: > On Tue, Feb 5, 2013 at 3:59 PM, Grant Edwards wrote: >> On 2013-02-05, Neil Cerutti wrote: >>> On 2013-02-05, Walter Hurry wrote: > Sorry, I'm a Linux guy. I have no clue what that means. Hooray for common sense! Python is great, but it's silly t

Re: Opinion on best practice...

2013-02-06 Thread Neil Cerutti
On 2013-02-05, Grant Edwards wrote: > On 2013-02-05, Neil Cerutti wrote: >> On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. >>> >>> Hooray for common sense! Python is great, but it's silly to use >>> Python (unless there is good reason) when a sim

Re: Opinion on best practice...

2013-02-06 Thread Anssi Saari
Dennis Lee Bieber writes: > PowerShell is meant to be used for administrative level scripting, > replacing such things as WSH. Yeah and WSH has been included since Windows 98... So Windows has been at least OK with shell scripting VBScript and JScript for the last 15 years or so. And I can

Re: Opinion on best practice...

2013-02-05 Thread rusi
On Feb 6, 6:55 am, Steven D'Aprano wrote: > I would not hesitate to use Python, or some other high-level language like > Ruby, over bash for anything non-trivial that I cared about. It might not > be as terse and compact as a well-written bash script, but that's a *good* > thing, and a poorly-wri

Re: Opinion on best practice...

2013-02-05 Thread Chris Angelico
On Wed, Feb 6, 2013 at 12:55 PM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> Python is not an "excellent option". It's a bad fit for shell >> scripting, it just happens to be way better than a weak shell. Having >> grown up on command.com, I found OS/2's cmd.exe to be a massive >> improvem

Re: Opinion on best practice...

2013-02-05 Thread Michael Torrie
On 02/05/2013 08:32 PM, Nobody wrote: > A shell script is only the better option if (almost) the *only* thing the > script needs to do is to execute commands. > > The moment you start trying to "process" data, it's time to put up with > the verbosity of subprocess.Popen() so that you can use a wel

Re: Opinion on best practice...

2013-02-05 Thread Nobody
On Tue, 05 Feb 2013 21:01:56 +, Walter Hurry wrote: > Hooray for common sense! Python is great, but it's silly to use Python > (unless there is good reason) when a simple shell script will do the job. A shell script is only the better option if (almost) the *only* thing the script needs to d

Re: Opinion on best practice...

2013-02-05 Thread Dan Stromberg
On Feb 5, 2013 6:00 PM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > Chris Angelico wrote: > > > Python is not an "excellent option". It's a bad fit for shell > > scripting, it just happens to be way better than a weak shell. Having > > grown up on command.com, I found OS/2'

Re: Opinion on best practice...

2013-02-05 Thread Steven D'Aprano
Chris Angelico wrote: > Python is not an "excellent option". It's a bad fit for shell > scripting, it just happens to be way better than a weak shell. Having > grown up on command.com, I found OS/2's cmd.exe to be a massive > improvement, and Windows's cmd.exe to be rather less impressive... but >

Re: Opinion on best practice...

2013-02-05 Thread Ian Kelly
On Tue, Feb 5, 2013 at 3:59 PM, Grant Edwards wrote: > On 2013-02-05, Neil Cerutti wrote: >> On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. >>> >>> Hooray for common sense! Python is great, but it's silly to use >>> Python (unless there is good r

Re: Opinion on best practice...

2013-02-05 Thread Chris Angelico
On Wed, Feb 6, 2013 at 10:00 AM, Grant Edwards wrote: > On 2013-02-05, Ethan Furman wrote: >> On 02/05/2013 01:39 PM, Neil Cerutti wrote: >>> Python is an excellent option for writing shell scripts, >>> particularly if your shell is cmd.exe. >> >> I believe having your shell be cmd.exe qualifies

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Ethan Furman wrote: > On 02/05/2013 01:39 PM, Neil Cerutti wrote: >> On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. >>> >>> Hooray for common sense! Python is great, but it's silly to use >>> Python (unless there is good reason) whe

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Neil Cerutti wrote: > On 2013-02-05, Walter Hurry wrote: >>> Sorry, I'm a Linux guy. I have no clue what that means. >> >> Hooray for common sense! Python is great, but it's silly to use >> Python (unless there is good reason) when a simple shell script >> will do the job. > > Pyt

Re: Opinion on best practice...

2013-02-05 Thread Ethan Furman
On 02/05/2013 01:39 PM, Neil Cerutti wrote: On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. Hooray for common sense! Python is great, but it's silly to use Python (unless there is good reason) when a simple shell script will do the job. Python is

Re: Opinion on best practice...

2013-02-05 Thread Neil Cerutti
On 2013-02-05, Walter Hurry wrote: >> Sorry, I'm a Linux guy. I have no clue what that means. > > Hooray for common sense! Python is great, but it's silly to use > Python (unless there is good reason) when a simple shell script > will do the job. Python is an excellent option for writing shell s

Re: Opinion on best practice...

2013-02-05 Thread Walter Hurry
On Tue, 05 Feb 2013 13:22:02 +, Grant Edwards wrote: > On 2013-02-05, Anthony Correia wrote: > >> I need to pick up a language that would cover the Linux platform. > > Well, you haven't really described what it is you're trying to do, but > it looks to me like bash and the usual set of shel

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Anthony Correia wrote: > I need to pick up a language that would cover the Linux platform. Well, you haven't really described what it is you're trying to do, but it looks to me like bash and the usual set of shell utilities (e.g. find) is what you need rather than Python. > I u

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Terry Reedy wrote: > On 2/4/2013 11:14 PM, Anthony Correia wrote: >> I need to pick up a language that would cover the Linux platform. I use >> Powershell for a scripting language on the Windows side of things. Very >> simple copy files script. Is this the best way to do it? >>

Re: Opinion on best practice...

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 11:35, schrieb Peter Otten: Ulrich Eckhardt wrote: [...] use os.path.walk(), because that doesn't first build a list and then iterate over the list but iterates over the single elements directly. [...] Not true. os.walk() uses os.listdir() internally. Oh. 8| Thanks for proofr

Re: Opinion on best practice...

2013-02-05 Thread rusi
> - Original Message - > > I need to pick up a language that would cover the Linux platform.  I > > use Powershell for a scripting language on the Windows side of > > things.  Very simple copy files script.  Is this the best way to do > > it? Have you seen/checked http://pash.sourceforge

Re: Opinion on best practice...

2013-02-05 Thread Peter Otten
Ulrich Eckhardt wrote: > separate variable but iterated over it directly. For large dirs, it > could also be better to use os.path.walk(), because that doesn't first > build a list and then iterate over the list but iterates over the single > elements directly. This avoids the memory allocation ov

Re: Opinion on best practice...

2013-02-05 Thread Jean-Michel Pichavant
- Original Message - > I need to pick up a language that would cover the Linux platform. I > use Powershell for a scripting language on the Windows side of > things. Very simple copy files script. Is this the best way to do > it? > > import os > > objdir = ("C:\\temp2") > colDi

Re: Opinion on best practice...

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 05:14, schrieb Anthony Correia: I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? import os objdir = ("C:\\temp2") Dro

Re: Opinion on best practice...

2013-02-05 Thread Terry Reedy
On 2/4/2013 11:14 PM, Anthony Correia wrote: I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? import os objdir = ("C:\\temp2") c

Re: Opinion on best practice...

2013-02-04 Thread Michael Torrie
On 02/04/2013 09:14 PM, Anthony Correia wrote: > I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? > > import os > > objdir = ("C:\\temp2") >

Opinion on best practice...

2013-02-04 Thread Anthony Correia
I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? import os objdir = ("C:\\temp2") colDir = os.listdir(objdir) for f in colDir: