On Wed, 22 Jun 2005 11:27:06 -0500, Jeff Epler wrote:
Why not just define the function yourself? Not every 3-line function
needs to be built in.
Of course I can code such a function, and I agree with the second
sentence, but I think that obtaining absolutes path is a task so commonly
needed
What's wrong with
(os.path.join(d, x) for x in os.listdir(d))
It's short, and easier to understand then some obscure option ;)
Andreas
On Thu, Jun 23, 2005 at 11:05:57AM +0200, Riccardo Galli wrote:
On Wed, 22 Jun 2005 11:27:06 -0500, Jeff Epler wrote:
Why not just define the function
On 6/22/05, Riccardo Galli [EMAIL PROTECTED] wrote:
I propose to add an 'abs' keyword which would make os.listdir return the
absolute path of files instead of a relative path.
What about os.listdir(dir='relative/path', abs=True)? Should listdir
call abspath on results? Should we add another
On Thu, 23 Jun 2005 11:34:02 +0200, Andreas Kostyrka wrote:
What's wrong with
(os.path.join(d, x) for x in os.listdir(d))
It's short, and easier to understand then some obscure option ;)
Andreas
how does it help in using list comprehension, as the ones in the first
post?
--
Riccardo
On Thu, 23 Jun 2005 12:56:08 +0300, Konstantin Veretennicov wrote:
On 6/22/05, Riccardo Galli [EMAIL PROTECTED] wrote:
I propose to add an 'abs' keyword which would make os.listdir return the
absolute path of files instead of a relative path.
What about os.listdir(dir='relative/path',
Riccardo Galli wrote:
On Thu, 23 Jun 2005 12:56:08 +0300, Konstantin Veretennicov wrote:
What about os.listdir(dir='relative/path', abs=True)? Should listdir call
abspath on results? Should we add another keyword rel? Would it complicate
listdir unnecessarily?
keyword dir not exists (don't
Konstantin Veretennicov wrote:
On 6/22/05, Riccardo Galli [EMAIL PROTECTED] wrote:
I propose to add an 'abs' keyword which would make os.listdir return the
absolute path of files instead of a relative path.
What about os.listdir(dir='relative/path', abs=True)? Should listdir
call abspath
Riccardo Galli wrote:
On Thu, 23 Jun 2005 11:34:02 +0200, Andreas Kostyrka wrote:
What's wrong with
(os.path.join(d, x) for x in os.listdir(d))
It's short, and easier to understand then some obscure option ;)
Andreas
how does it help in using list comprehension, as the ones in the
On Thu, 23 Jun 2005 13:25:06 +0200, Daniel Dittmar wrote:
He probably meant that a 'join' option would be more natural than an 'abs'
option. After all, your examples use os.path.join to create a valid path
that can be used as the argument to other module os functions. Whether the
results are
Am Wed, 22 Jun 2005 17:57:14 +0200 schrieb Riccardo Galli:
Hi,
I noticed that when I use os.listdir I need to work with absolute paths
90% of times.
While I can use a for cycle, I'd prefere to use a list comprehension,
but it becomes too long.
Hi,
I like it. But as you noticed, too, join
Hi All--
Thomas Guettler wrote:
I like it. But as you noticed, too, join would be better than abs.
Example:
# mylistdir.py
import os
import sys
def mylistdir(dir, join=False):
for file in os.listdir(dir):
yield os.path.join(dir, file)
print
On Thu, 23 Jun 2005 09:21:55 -0600, Ivan Van Laningham wrote:
Mmmm, how about:
# mylistdir.py
import os, os.path
import sys
def mylistdir(dir, join=False):
for file in os.listdir(dir):
if join:
yield join(dir, file)
else:
yield file
print
Hi,
I noticed that when I use os.listdir I need to work with absolute paths
90% of times.
While I can use a for cycle, I'd prefere to use a list comprehension,
but it becomes too long.
I propose to add an 'abs' keyword which would make os.listdir return the
absolute path of files instead of a
Why not just define the function yourself? Not every 3-line function
needs to be built in.
def listdir_joined(path):
return [os.path.join(path, entry) for entry in os.listdir(path)]
dirs = [x for x in listdir_joined(path) if os.path.isdir(x)]
path_size = [(x, getsize(x)) for x in
Riccardo Galli wrote:
I noticed that when I use os.listdir I need to work with absolute paths
90% of times.
While I can use a for cycle, I'd prefere to use a list comprehension,
but it becomes too long.
### e.g. 1 part 1 - getting a list of directories ###
dirs=[]
for i in
Peter Hansen wrote:
Using Jason Orendorff's path module, all this code basically collapses
down to this beauty (with your variable path renamed to myPath to
avoid a name collision):
This has to be the non-stdlib library I use the most. It's a great module.
--
Michael Hoffman
--
16 matches
Mail list logo