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 30520
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.pa th.join(dirname , filespec))
cya,
Eric
--
---
s- should be removed to contact me...
Erik Max Francis <ma*@alcyone.co m> wrote in message news:<3F******* ********@alcyon e.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.co m> wrote in message news:<3F******* ********@alcyon e.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.co m> wrote: Jeremy Fincher wrote:
Erik Max Francis <ma*@alcyone.co m> wrote in message news:<3F******* ********@alcyon e.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(patte rn): print 'there is at least one file matching %r'%pattern
else: print 'no files match the %r pattern'%patter n
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.co m> wrote in message news:<3F******* *******@alcyone .com>... Jeremy Fincher wrote:
Erik Max Francis <ma*@alcyone.co m> wrote in message news:<3F******* ********@alcyon e.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. I know the
physical location of the image(s) in question, and figured I'd use
os.path.exists to see if each file exists. A quick test in the
interpreter yields:
>>> os.path.exists(u'S:/Scans/Projects/2004/TJ/04TJ0267.jpg')
True
|
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 "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.exists('Lib/os.py')
True # expected
|
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 Qty
SSW-101-01-T-D 1780
SSW-101-01-T-D 1780
SSW-102-01-G-D 8900
|
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 I get the following
stack trace:
System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\". at System.IO.__Error.WinIOError
|
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 CSV file without any issues only if all the fields are not null. If any field is blank, it moves the values to the left and displays the value under invalid column.
Example is shown below:
A part of CSV file.
I am reading the first row as...
| |
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 requests before
answering to the client. Please allow me to show and example since it
will illustrate the point well.
User types: http://domain.com/myapp/restofpath.html
|
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:
-----------------
import imp
def loader(mname, mpath):
fp, pathname, description = imp.find_module(mname,)
|
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 inputString = Convert.ToString(reader);
byte AttachmentByte;
AttachmentByte = StringToByteArray(inputString);
string dir = "";
|
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 http://mghospedagem.com/images/controlpanel.jpg
instead of
http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg
As u see, there's the website URL before the image URL.
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |