could ildg wrote:
> I want to know this because I want to zip a directory and all of its
> sub-files and sub-directories to a zip file. zipfile module of python
> will not automatically include the empty directories, so I have to
> check if a dir is empty and do this manually
Can you make work
could ildg wrote:
> On 8/8/05, Peter Hansen <[EMAIL PROTECTED]> wrote:
>>could ildg wrote:
>>>I want to check if a folder named "foldername" is empty.
>>>I use os.listdir(foldername)==[] to do this,
>>>but it will be very slow if the folder has a lot of sub-files.
>>>Is there any efficient ways to
On 8/8/05, Peter Hansen <[EMAIL PROTECTED]> wrote:
> could ildg wrote:
> > I want to check if a folder named "foldername" is empty.
> > I use os.listdir(foldername)==[] to do this,
> > but it will be very slow if the folder has a lot of sub-files.
> > Is there any efficient ways to do this?
>
> I'
Mike Meyer wrote:
> Just out of curiosity, is there an OS out there where you can have the
> permissions needed to delete a directory without having the
> permissions needed to create it appropriately?
Not an OS, but AFS has a wider set of permissions (RLIDWKA - which, if I
remember correctly, ar
[EMAIL PROTECTED] writes:
> On standard Unix fileystems, one way to check for this is to check that the
> st_nlink of the directory is 2.
In that case you only know that the directory doesn't have any
subdirectories. It may still contain ordinary files and other
non-directories.
Bernhard
-
On Mon, 08 Aug 2005 09:03:39 -0400,
Mike Meyer <[EMAIL PROTECTED]> wrote:
> Just out of curiosity, is there an OS out there where you can have the
> permissions needed to delete a directory without having the
> permissions needed to create it appropriately?
Depending on your definition of "out th
James Dennett <[EMAIL PROTECTED]> writes:
> Reinhold Birkenfeld wrote:
>
>> could ildg wrote:
>>
>>>I want to check if a folder named "foldername" is empty.
>>>I use os.listdir(foldername)==[] to do this,
>>>but it will be very slow if the folder has a lot of sub-files.
>>>Is there any efficient wa
could ildg wrote:
> I want to check if a folder named "foldername" is empty.
> I use os.listdir(foldername)==[] to do this,
> but it will be very slow if the folder has a lot of sub-files.
> Is there any efficient ways to do this?
I'm just curious to know under what circumstances where it's import
Reinhold Birkenfeld wrote:
> could ildg wrote:
>
>>I want to check if a folder named "foldername" is empty.
>>I use os.listdir(foldername)==[] to do this,
>>but it will be very slow if the folder has a lot of sub-files.
>>Is there any efficient ways to do this?
>
>
> try:
> os.rmdir(path)
>
On standard Unix fileystems, one way to check for this is to check that the
st_nlink of the directory is 2. However, even on Unix systems this isn't
guaranteed for all filesystem types.
Of course, finding whether a directory is empty is inherently racy: a file
could be created between the time yo
could ildg
> so you mean that this is not platform-independent?
Your existing code is platform-independent but I think for faster
code you will need to write platform-dependent code. FindFirstFile is
only available on Windows.
Neil
--
http://mail.python.org/mailman/listinfo/python-lis
Reinhold Birkenfeld wrote:
> could ildg wrote:
>
>>I want to check if a folder named "foldername" is empty.
>>I use os.listdir(foldername)==[] to do this,
>>but it will be very slow if the folder has a lot of sub-files.
>>Is there any efficient ways to do this?
>
>
> try:
> os.rmdir(path)
>
could ildg wrote:
> I want to check if a folder named "foldername" is empty.
> I use os.listdir(foldername)==[] to do this,
> but it will be very slow if the folder has a lot of sub-files.
> Is there any efficient ways to do this?
try:
os.rmdir(path)
empty = True
except OSError:
empty
Thank you .
so you mean that this is not platform-independent?
On 8/8/05, Neil Hodgson <[EMAIL PROTECTED]> wrote:
> could ildg:
>
> > I want to check if a folder named "foldername" is empty.
> > I use os.listdir(foldername)==[] to do this,
> > but it will be very slow if the folder has a lot of s
could ildg:
> I want to check if a folder named "foldername" is empty.
> I use os.listdir(foldername)==[] to do this,
> but it will be very slow if the folder has a lot of sub-files.
> Is there any efficient ways to do this?
The first thing to do is measure the performance of this operation
I want to check if a folder named "foldername" is empty.
I use os.listdir(foldername)==[] to do this,
but it will be very slow if the folder has a lot of sub-files.
Is there any efficient ways to do this?
Thanks~
--
http://mail.python.org/mailman/listinfo/python-list
16 matches
Mail list logo