On 20 July 2017 at 21:43, Skip Montanaro wrote:
> scandir returns an iterator of DirEntry objects which contain more
> > information than the mere name.
> >
>
> As I recall, the motivation for scandir was to avoid subsequent system
> calls, so it will be slower than listd
On Thu, 20 Jul 2017 03:33 pm, Torsten Bronger wrote:
> Hallöchen!
>
> With a 24,000 files directory on an SSD running Ubuntu,
>
> #!/usr/bin/python3
>
> import os, time
>
>
> start = time.time()
> list(os.listdir("/home/bronger/.save
scandir returns an iterator of DirEntry objects which contain more
> information than the mere name.
>
As I recall, the motivation for scandir was to avoid subsequent system
calls, so it will be slower than listdir the way you've tested it. If you
add in the cost of fetching the other
On 7/20/2017 1:33 AM, Torsten Bronger wrote:
Hallöchen!
With a 24,000 files directory on an SSD running Ubuntu,
#!/usr/bin/python3
import os, time
start = time.time()
list(os.listdir("/home/bronger/.saves"))
listdir returns a list of na
prin
Hallöchen!
With a 24,000 files directory on an SSD running Ubuntu,
#!/usr/bin/python3
import os, time
start = time.time()
list(os.listdir("/home/bronger/.saves"))
print("listdir:", time.time() - start)
start = time.time()
list(os.scandir(&
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/
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
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
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
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"):
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
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.
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
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
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
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
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 file.endswith(".py"):
print(fil
Hi!
Sorry. The path was wrong! "backup_redmine <> redmine_backup"... :-(
Thanks:
dd
--
http://mail.python.org/mailman/listinfo/python-list
up on execution.
Everything is same, but when I check os.listdir() on this dir, I see
only two folders.
5 elements are here:
Files_Zipped (dir)
MySQL_Dump (dir)
Log (dir)
Log2 (dir)
BackupRedmine.py (the script)
The listdir show only:
Files_Zipped
MySQL_Dump
(It don't see itself!)
Because it don
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
> 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 "*.*
en some/all caches have forgot about the
directory. If I query the directory again (multiple times) listdir() will
finally return the content of the directory.
The "DOS" command DIR has no problem listing the same directory.
Configuration:
>>> sys.version
'2.5.4 (r254:67916, D
#x27;Invalid switch - "*.*".'
>
> Probably because on the command-line, / means a command-line option.
> Been a while since I used DOS.
>
> Try this instead:
>
> dir f:\code\python\pgmgallery\*.*"
>
> David.
Try typing listdir( '.' ), which
On Sat, Apr 26, 2008 at 7:56 PM, jimgardener <[EMAIL PROTECTED]> wrote:
>
> > * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*"
> >
>
> that causes a message 'Invalid switch - "*.*".'
>
>
Probably because on the command-line, / means a command-line option.
Been a while
> * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*"
>
that causes a message 'Invalid switch - "*.*".'
> * Try using other directories under F: drive in your program and see> when
> you start hitting the problem.
i tried that..on some directories in the same drive this
list of filenames using listdir
pgmdir="f:\code\python\pgmgallery" # where i have pgm files
g2=listdir(pgmdir)
i get the following error
WindowsError: [Error 123] The filename, directory name, or volume
label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*'
i am run
On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote:
> hi
> i have a directory containing .pgm files of P5 type.i wanted to read
> the pixel values of these files ,so as a firststep i wrote code to
> make a list of filenames using listdir
>
> pgmdir="f:\code\python\pgm
>
> i get the following error
> WindowsError: [Error 123] The filename, directory name, or volume
> label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*'
>
> i am running python on winXP ..can anyone tell me why i get this
> error?
> --
>From some Googling, it looks like this error ca
hi
i have a directory containing .pgm files of P5 type.i wanted to read
the pixel values of these files ,so as a firststep i wrote code to
make a list of filenames using listdir
pgmdir="f:\code\python\pgmgallery" # where i have pgm files
g2=listdir(pgmdir)
i get the follo
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
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-решения на
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
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
Hello!
Is there any easy way to list files using bash-like patterns? Something like
listfiles("/var/log/*.log"), listfiles("/var/{cache,run}/*").
Also, I'll need something like listfiles("/tmp/**/*.tmp"), where ** is
unlimited number of folders (like is zsh).
Thanks and sorry for my English.
--
[EMAIL PROTECTED] wrote:
> I have the following code which list out all the files/directories
> under the current directory.
>
> But how can I find out if 'f' is a directory?
>
> for f in os.listdir("."):
> // how can I check if 'f' a directory?
>
Try os.path.isdir()
--
-
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> for f in os.listdir("."):
> // how can I check if 'f' a directory?
Your two approaches are 1) use os.stat (or stat.stat) and check the
mode bits; or 2) use os.listdir and catch the OSError exception you
get if you use it on a non-directory.
--
I have the following code which list out all the files/directories
under the current directory.
But how can I find out if 'f' is a directory?
for f in os.listdir("."):
// how can I check if 'f' a directory?
--
http://mail.python.org/mailman/listinfo/python-list
or 3 (network) calls for each file. os.walk just uses
listdir.
Robert
--
http://mail.python.org/mailman/listinfo/python-list
robert wrote:
> I want to get the files and sizes and times etc. stats of a dir fast.
> os.listdir & iterating with os.stat seems not to run at optimal speed for
> network folders. Is there a faster possibility? (both for Win & *nix ; best
> platform independent)
>
>
> Robert
An alternative is
In message <[EMAIL PROTECTED]>,
Thomas Thomas <[EMAIL PROTECTED]> writes
>Hi All,
>
>I am trying to access a mapped network drive folder. everything works fine
>normally. But when i run the application as service I am getting the error
>
>Traceback (most recent call last):
> File "docBoxApp.py",
Thomas Thomas wrote:
> Hi All,
>
> I am trying to access a mapped network drive folder. everything works fine
> normally. But when i run the application as service I am getting the error
>
> Traceback (most recent call last):
> File "docBoxApp.py", line 129, in ?
> File "core\PollFiles.pyc",
On Thu, 25 May 2006, Thomas Thomas wrote:
> I am trying to access a mapped network drive folder. everything works
> fine normally. But when i run the application as service I am getting
> the error
The error is on the line:
for filename in os.listdir(folder):#line 25
and I have to ass
Hi All,
I am trying to access a mapped network drive folder. everything works fine
normally. But when i run the application as service I am getting the error
Traceback (most recent call last):
File "docBoxApp.py", line 129, in ?
File "core\PollFiles.pyc", line 332, in doPoll
File "core\Poll
g. 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. I then want to move those files into a zip archive
> for the a
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
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
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. I then want to move those files
[EMAIL PROTECTED] wrote:
> Unluckily, to capture the stdout I have to redirect it to a file...
> I hoped that this could work ...
> lF=sys.stdin.readline(os.system("ls -1 *.py"))
hint: look up "os.popen" and "subprocess" in the library reference.
--
http://mail.python.org/mailman/listinfo/p
Am Thu, 26 May 2005 06:31:40 -0700 schrieb qwweeeit:
Hi,
> ls -1 *.py (for the filenames only) or
This can be done with the module "glob" of the standard library.
HTH,
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
to obtain a file list from a dir you can use:
import os, sys
try:
. sExtension=sys.argv[1]
. sPath=sys.argv[2]
except:
. sExtension=""
. sPath='.'
lF=os.listdir(sPath)
# to remove from the list also the names of backup files
lF=filter(lambda lF: '~' not in lF and sExtension in lF,lF
50 matches
Mail list logo