Hi,
How can I check for the xistence of any file that matches a wildcard?
For example: ppis-*.iss
os.path.exists() doesn't expand the wildcard... 7 29982
Fernando Rodriguez wrote: How can I check for the xistence of any file that matches a wildcard?
For example: ppis-*.iss
os.path.exists() doesn't expand the wildcard...
Use glob.glob and then os.path.exists in a loop.
--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \
\__/ Get married, but never to a man who is home all day.
-- George Bernard Shaw
Fernando Rodriguez wrote: Hi,
How can I check for the xistence of any file that matches a wildcard?
For example: ppis-*.iss
os.path.exists() doesn't expand the wildcard...
have you taken a look at glob.glob?
import glob, os
dirname="."
filespec="ppis-*.iss"
print glob.glob(os.path.join(dirname, filespec))
cya,
Eric
--
---
s- should be removed to contact me...
Erik Max Francis <ma*@alcyone.com> wrote in message news:<3F***************@alcyone.com>... Fernando Rodriguez wrote:
How can I check for the xistence of any file that matches a wildcard?
For example: ppis-*.iss
os.path.exists() doesn't expand the wildcard...
Use glob.glob and then os.path.exists in a loop.
Wouldn't the glob.glob only return files that actually exist?
Jeremy
Jeremy Fincher wrote: Erik Max Francis <ma*@alcyone.com> wrote in message news:<3F***************@alcyone.com>...
Fernando Rodriguez wrote:
How can I check for the xistence of any file that matches a wildcard?
For example: ppis-*.iss
os.path.exists() doesn't expand the wildcard...
Use glob.glob and then os.path.exists in a loop.
Wouldn't the glob.glob only return files that actually exist?
Sure, but isn't that what he wants? He wrote, "the [existence] of any
file that maches a wildcard." He's obviously talking about existing
files.
Besides, what else could expanding a wildcard mean except enumerating
every possible match?
--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
__ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/ \
\__/ Why don't you grow up for crying out loud?
-- Capt. Benjamin "Hawkeye" Pierce
On Mon, 17 Nov 2003 11:09:58 -0800, Erik Max Francis <ma*@alcyone.com> wrote: Jeremy Fincher wrote:
Erik Max Francis <ma*@alcyone.com> wrote in message news:<3F***************@alcyone.com>...
> Fernando Rodriguez wrote: > > > How can I check for the xistence of any file that matches a > > wildcard? > > > > For example: ppis-*.iss > > > > os.path.exists() doesn't expand the wildcard... > > Use glob.glob and then os.path.exists in a loop.
Wouldn't the glob.glob only return files that actually exist?
Sure, but isn't that what he wants? He wrote, "the [existence] of any file that maches a wildcard." He's obviously talking about existing files.
Besides, what else could expanding a wildcard mean except enumerating every possible match?
Sure, but then what? Maybe the OP was only interested if _any_ matches existed. E.g.,
pattern = 'ppis-*.iss'
if glob.glob(pattern): print 'there is at least one file matching %r'%pattern
else: print 'no files match the %r pattern'%pattern
might be reasonable to do in some context -- without looking at the actual matches, if any.
Maybe this is what Jeremy had in mind (a lot of mind reading around here ;-)
Regards,
Bengt Richter
On 17 Nov 2003 22:17:25 GMT, bo**@oz.net (Bengt Richter) wrote: Besides, what else could expanding a wildcard mean except enumerating every possible match?
Sure, but then what? Maybe the OP was only interested if _any_ matches existed. E.g.,
Yes, that exactly what I wanted, and the glob trick works fine. Thanks. :-)
Erik Max Francis <ma*@alcyone.com> wrote in message news:<3F**************@alcyone.com>... Jeremy Fincher wrote:
Erik Max Francis <ma*@alcyone.com> wrote in message news:<3F***************@alcyone.com>...
Fernando Rodriguez wrote:
> How can I check for the xistence of any file that matches a > wildcard? > > For example: ppis-*.iss > > os.path.exists() doesn't expand the wildcard...
Use glob.glob and then os.path.exists in a loop.
Wouldn't the glob.glob only return files that actually exist?
Sure, but isn't that what he wants? He wrote, "the [existence] of any file that maches a wildcard." He's obviously talking about existing files.
Ah, you misunderstand; my problem was with the "and then
os.path.exists in a loop" part, since, by definition, the files
returned by glob.glob will exist :) I was just trying to kindly point
out that os.path.exists isn't needed for his purposes. I guess I
could've been more clear :)
Jeremy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Robert Brewer |
last post by:
I've got a webapp which is behaving oddly. I want to include an image on
the webpage, but only if the physical file exists; if it doesn't, I
don't want an img element to generate an ugly blank box....
|
by: Pierre Quentel |
last post by:
os.path.exists(path) returns True if "path" exists
But on Windows it also returns True for "path" followed by any number of
dots :
Python 2.4 (#60, Nov 30 2004, 11:49:19) on win32
Type...
|
by: Randy Weber |
last post by:
I am getting unexpected results with a Like Query using ASP and an
Access database.
This query -
SELECT PN, Qty From Inventory Where PN Like 'SSW-10%';
returns what I expect:
PN ...
|
by: Sheldon Cohen |
last post by:
Hello,
I am using c# and running a site that is on a shared
host. The code in question is supposed to create a new
directory that is coming out of a text box.
It works fine on my computer, but...
|
by: Anish G |
last post by:
Hi,
I have an issue with reading CSV files.
I am to reading CSV file and putting it in a Datatable in C#. I am using a regular expression to read the values. Below is the code. Now, it reads...
|
by: TATrader |
last post by:
Dearest Colleagues,
I was suddenly having a sharp pain in locating information about a
design capability in PHP that exists in Java servlets.
In Java, I can preprocess, via a filter, some HTTP...
|
by: David Hirschfield |
last post by:
I'm not entirely sure what's going on here, but I suspect it's related
to my general lack of knowledge of the python import internals.
Here's the setup:
module: tester.py:
-----------------...
|
by: Krantor |
last post by:
Hi all,
i am quite new to c# and was wondering if i could get assistance on an issue im having with writing a binary file from the database to my local machine, this is the code i have:
string...
|
by: matheussousuke |
last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails.
The goal is: Make it send the email with the URL...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |