Re: [OT] Re: output from external commands

2005-10-25 Thread Terry Hancock
On Monday 24 October 2005 09:04 pm, darren kirby wrote: quoth the Fredrik Lundh: (using either on the output from glob.glob is just plain silly, of course) Silly? Sure. os.listdir() is more on point. Never said I was the smartest. However, I will defend my post by pointing out that at the

Re: [OT] Re: output from external commands

2005-10-25 Thread Mike Meyer
Terry Hancock [EMAIL PROTECTED] writes: I think Mr. Lundh's point was only that the output from glob.glob is already guaranteed to be strings, so using either '%s'%f or str(f) is superfluous. Just for the record - this was why I asked what the point was in the first place. mike -- Mike

Re: [OT] Re: output from external commands

2005-10-25 Thread Bengt Richter
On Tue, 25 Oct 2005 10:10:39 -0500, Terry Hancock [EMAIL PROTECTED] wrote: On Monday 24 October 2005 09:04 pm, darren kirby wrote: quoth the Fredrik Lundh: (using either on the output from glob.glob is just plain silly, of course) Silly? Sure. os.listdir() is more on point. Never said I was

Re: output from external commands

2005-10-24 Thread darren kirby
quoth the James Colannino: Hey everyone. First off, I'm new to the list. I had had a little bit of experience with Perl before discovering Python. The more Python I learn, the more I love it :) I just have a quick question to ask. I know that this is probably a simple question, but I've

Re: output from external commands

2005-10-24 Thread Kent Johnson
darren kirby wrote: quoth the James Colannino: So, for example, in Perl I could do something like: @files = `ls`; So I guess I'm looking for something similiar to the backticks in Perl. Forgive me if I've asked something that's a bit basic for this list. Any help would be greatly appreciated :)

Re: output from external commands

2005-10-24 Thread Mike Meyer
darren kirby [EMAIL PROTECTED] writes: If all you want is filenames this will work: import glob files = [%s % f for f in glob.glob(*)] What's the point of doing %s % f? How is this different from just file = [f for f in glob.glob(*)]? mike -- Mike Meyer [EMAIL PROTECTED]

Re: output from external commands

2005-10-24 Thread Peter Hansen
Mike Meyer wrote: darren kirby [EMAIL PROTECTED] writes: If all you want is filenames this will work: import glob files = [%s % f for f in glob.glob(*)] What's the point of doing %s % f? How is this different from just file = [f for f in glob.glob(*)]? Answering narrowly, the difference

Re: output from external commands

2005-10-24 Thread James Colannino
Kent Johnson wrote: import os files = os.listdir('.') Thanks, that's good to know. I still need to use os.popen() for a few things, but I'll be needing filenames also, so when I try to get filenames I'll use the above. James -- My blog: http://www.crazydrclaw.com/ My homepage:

Re: output from external commands

2005-10-24 Thread Terry Hancock
On Monday 24 October 2005 11:24 am, Peter Hansen wrote: Answering narrowly, the difference is that using %s calls str() on the items in the result list, while your suggestion does not. (Why not just use str(f) instead of the less clear '%s' % f? would be a valid question too though.) The

Re: output from external commands

2005-10-24 Thread Fredrik Lundh
Terry Hancock wrote: Note also that for those who count, str(f) is exactly as long (in keystrokes) as '%s'%f, making the just a matter of opinion. the % implementation still has to create an overallocated output buffer, parse the format string, call str() on the argument, verify the result,

[OT] Re: output from external commands

2005-10-24 Thread darren kirby
quoth the Fredrik Lundh: (using either on the output from glob.glob is just plain silly, of course) Silly? Sure. os.listdir() is more on point. Never said I was the smartest. However, I will defend my post by pointing out that at the time it was the only one that actually included code that

Re: [OT] Re: output from external commands

2005-10-24 Thread Steven Bethard
darren kirby wrote: quoth the Fredrik Lundh: (using either on the output from glob.glob is just plain silly, of course) [snip] It is things like this that make me wary of posting to this list, either to help another, or with my own q's. All I usually want is help with a specific

Re: [OT] Re: output from external commands

2005-10-24 Thread Tony Meyer
On 25/10/2005, at 3:36 PM, Steven Bethard wrote: I wouldn't fret too much about a sharp remark from Fredrik Lundh. They're pretty much all that way. ;) [...] It takes a little training to get used to him, but if you can look past the nasty bite, he's really a valuable resource around here.

output from external commands

2005-10-23 Thread James Colannino
Hey everyone. First off, I'm new to the list. I had had a little bit of experience with Perl before discovering Python. The more Python I learn, the more I love it :) I just have a quick question to ask. I know that this is probably a simple question, but I've been googling around, and

Re: output from external commands

2005-10-23 Thread Mike Meyer
James Colannino [EMAIL PROTECTED] writes: Hey everyone. First off, I'm new to the list. I had had a little bit of experience with Perl before discovering Python. The more Python I learn, the more I love it :) I just have a quick question to ask. I know that this is probably a simple

Re: output from external commands

2005-10-23 Thread James Colannino
Mike Meyer wrote: This is a scripting language feature. Python doesn't have direct support for it, any more than C++ does. To get that functionality, you want to use either the os.popen function, or - preferable, but only available in newer Pythons - the subprocess module. Thanks. James --