Re: listdir

2016-09-05 Thread breamoreboy
On Monday, September 5, 2016 at 4:34:45 PM UTC+1, Rustom Mody wrote: > So what do you get when you replace the if-else with a simple: print(file) ? > > [And BTW dont use the variable name “file” its um sacred] Only in Python 2, it's gone from the built-ins in Python 3 https://docs.python.org/3/

Re: listdir

2016-09-05 Thread Chris Angelico
On Tue, Sep 6, 2016 at 2:29 AM, Smith wrote: >> What exactly are you expecting the 'break' to do here? Can you explain >> to me the intent of your code? >> >> ChrisA >> > I'd like to create a script that searches the directory .py files. > If the script does not find the file extension .py would r

Re: listdir

2016-09-05 Thread Smith
What exactly are you expecting the 'break' to do here? Can you explain to me the intent of your code? ChrisA I'd like to create a script that searches the directory .py files. If the script does not find the file extension .py would return the error message "File Not Found". -- https://mai

Re: listdir

2016-09-05 Thread Smith
On 05/09/2016 17:57, jmp wrote: Is that what you're expecting ? A slightly different version: import glob, os a = input("search for files with the extension .py into directory: ") print glob.glob(os.path.join(a, '*.py')) jm Thank you Sorry, but i'm newbie :-( -- https://mail.python.org/ma

Re: listdir

2016-09-05 Thread jmp
On 09/05/2016 05:41 PM, Smith wrote: Il 05/09/2016 17:34, Rustom Mody ha scritto: So what do you get when you replace the if-else with a simple: print(file) a = input("search for files with the extension .py into directory: ") for file in os.listdir(a): if file.endswith(".py"):

Re: listdir

2016-09-05 Thread Smith
Il 05/09/2016 17:34, Rustom Mody ha scritto: So what do you get when you replace the if-else with a simple: print(file) a = input("search for files with the extension .py into directory: ") for file in os.listdir(a): if file.endswith(".py"): print(file) search for fil

Re: listdir

2016-09-05 Thread Chris Angelico
On Tue, Sep 6, 2016 at 1:27 AM, Smith wrote: > Hello to all, > I wanted to know because even though the files are present on the directory > I write input gives me "file not found". > You can help me? > Thank you > > a = input("Digita la directory dove vuoi trovare i file py: ") > for file in os.

Re: listdir

2016-09-05 Thread Chris Angelico
On Tue, Sep 6, 2016 at 1:34 AM, Rustom Mody wrote: > [And BTW dont use the variable name “file” its um sacred] Nah, that part's fine. Python isn't religious about builtins. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: listdir

2016-09-05 Thread Rustom Mody
So what do you get when you replace the if-else with a simple: print(file) ? [And BTW dont use the variable name “file” its um sacred] -- https://mail.python.org/mailman/listinfo/python-list

Re: listdir

2016-09-05 Thread jmp
On 09/05/2016 05:27 PM, Smith wrote: Hello to all, I wanted to know because even though the files are present on the directory I write input gives me "file not found". You can help me? Thank you a = input("Digita la directory dove vuoi trovare i file py: ") for file in os.listdir(a): if fi

Re: listdir

2016-09-05 Thread Smith
Il 05/09/2016 17:27, Smith ha scritto: Hello to all, I wanted to know because even though the files are present on the directory I write input gives me "file not found". You can help me? Thank you a = input("Digita la directory dove vuoi trovare i file py: ") for file in os.listdir(a): if f

RE: listdir reports [Error 1006] The volume for a file has been externally altered so that the opened file is no longer valid

2009-01-08 Thread Per Olav Kroka
FYI: the '/*.*' is part of the error message returned. -Original Message- From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert Sent: Wednesday, January 07, 2009 6:40 PM To: Per Olav Kroka Cc: python-list@python.org Subject: Re: listdir reports [Error

Re: listdir reports [Error 1006] The volume for a file has been externally altered so that the opened file is no longer valid

2009-01-07 Thread Chris Rebert
> PS: Why does the listdir() function add '*.*' to the path? Don't know what you're talking about. It doesn't do any globbing or add "*.*" to the path. Its exclusive purpose is to list the contents of a directory, so /in a sense/ it does add "*.*", but then not adding "*.*" would make the function

Re: listdir() with mask

2007-12-14 Thread grflanagan
On Dec 14, 2:00 pm, "Vladimir Rusinov" <[EMAIL PROTECTED]> wrote: >Is there any easy way to list files using bash-like patterns? Something like >listfiles("/var/log/*.log"), listfiles("/var/{cache,run}/*"). > On 12/14/07, Jeff McNeil <[EMAIL PROTECTED]> wrote: > > > > > Sure is.. check out the glob

Re: listdir() with mask

2007-12-14 Thread Vladimir Rusinov
On 12/14/07, Jeff McNeil <[EMAIL PROTECTED]> wrote: > > Sure is.. check out the glob module: > http://www.python.org/doc/current/lib/module-glob.html (Official) > http://blog.doughellmann.com/2007/07/pymotw-glob.html (PyMOTW) > Thanks a lot! -- Vladimir Rusinov GreenMice Solutions: IT-решения на

Re: listdir() with mask

2007-12-14 Thread Rick Dooling
On Dec 14, 1:56 am, "Vladimir Rusinov" <[EMAIL PROTECTED]> wrote: glob or fnmatch http://docs.python.org/lib/module-glob.html rd -- http://mail.python.org/mailman/listinfo/python-list

Re: listdir() with mask

2007-12-14 Thread Jeff McNeil
Sure is.. check out the glob module: http://www.python.org/doc/current/lib/module-glob.html (Official) http://blog.doughellmann.com/2007/07/pymotw-glob.html (PyMOTW) Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "cre

Re: listdir() - any way to limit # of file entries?

2006-02-22 Thread Roger Upole
You can use win32file.FindFilesIterator to loop thru the files without creating a huge list of everthing in the folder. hth Roger "Peter A. Schott" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I want to build a program that does some archiving. We have several pr

Re: listdir() - any way to limit # of file entries?

2006-02-22 Thread Larry Bates
Peter A. Schott wrote: > I want to build a program that does some archiving. We have several programs > that have been dumping files into a folder (one folder) for some time now. I > want to limit the number of files returned by listdir to avoid trying to > build a > list with tons of entries.

Re: listdir() - any way to limit # of file entries?

2006-02-22 Thread Paul Rubin
Peter A. Schott <[EMAIL PROTECTED]> writes: > Is there any way to build a list of the first 1000 files or so in a folder? The obvious way is first_1000 = os.listdir()[:1000] That does build a potentially bigger list in memory before chopping off the 1000 elements, but unless you're running ou