[issue7017] os.listdir behaviour

2009-09-29 Thread Chris Adamson

New submission from Chris Adamson :

When I iterate through a list created using os.listdir it seems to grow
as I create files in that directory. I want a static copy of the list of
files in the directory prior to me writing new files into it.

Here is my code:

fileList = os.listdir(temporaryDirectory)

for curFile in fileList:
   # print the file list to see if it is indeed growing
   print FileList
   fp = file(os.path.join(temporaryDirectory, "." + curFile), 'w')
   # write stuff
   fp.close()

Here is the output:

['a', 'b', 'c']
['a', 'b', 'c', '.a']
['a', 'b', 'c', '.a', '.b']
['a', 'b', 'c', '.a', '.b', '.c']

So the list is growing and eventually curFile iterates through the list
of files that were created. This behaviour was unwanted in my case and I
couldn't find any documentation about this.

--
components: None
messages: 93255
nosy: bigaddo
severity: normal
status: open
title: os.listdir behaviour
type: behavior
versions: Python 2.6

___
Python tracker 
<http://bugs.python.org/issue7017>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7017] os.listdir behaviour

2009-09-29 Thread Chris Adamson

Chris Adamson  added the comment:

I think I found my problem. Since I didn't *COPY* the array that I
created with os.listdir I was actually appending to it, my bad.

--
status: pending -> closed

___
Python tracker 
<http://bugs.python.org/issue7017>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com