hi
i have script like this:
from fnmatch import fnmatch
from glob import glob
.....
....
f = ['file1','file2' ,'file3']
r = "d:\\somepa th"
pat = "*.bat"
listof_files = [i for i in f if not fnmatch(os.path .join(r,i),pat) and
os.path.isfile( os.path.join(r, i))]
....
...
I get this error:
File "C:\Python24\Li b\fnmatch.py", line 37, in fnmatch
pat = os.path.normcas e(pat)
File "C:\Python24\li b\ntpath.py", line 42, in normcase
return s.replace("/", "\\").lower ()
AttributeError: replace
But when i do everything in interactive, there is no problem.. What
could be wrong with the script?
My purpose is to find a list of files that does not match pat...
thanks 2 2014 s9************@ yahoo.com wrote: listof_files = [i for i in f if not fnmatch(os.path .join(r,i),pat) and os.path.isfile( os.path.join(r, i))] ... ..
I get this error: File "C:\Python24\Li b\fnmatch.py", line 37, in fnmatch pat = os.path.normcas e(pat) File "C:\Python24\li b\ntpath.py", line 42, in normcase return s.replace("/", "\\").lower () AttributeError: replace
But when i do everything in interactive, there is no problem.. What could be wrong with the script?
nothing, from what I can tell.
did you verify that the code you posted really have the problem (it does
use the 'os' module which isn't important, and doesn't use 'glob' which
is imported, so chances are that you messed something up on the way to
comp.lang.pytho n).
what do you get if you add
print repr(pat), type(pat)
just before the list comprehension ?
</F>
> did you verify that the code you posted really has the problem (it does use the 'os' module which isn't important
message.replace ("important" , "imported") This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ruby Tuesday |
last post by:
In a directory, how to find an image file with part of its filename is known
and the file extension could be one of the following(jpg, tiff, bmp,png).
The filename always begin between 1 to 3 alphabet, then a dash(-), and
between 1-4 set of numbers and the extension could be in one of the
following(in order of importance) - jpg, bmp, tif.
If I know part/full of its filename, find the 1st match(just in case there
are similar filename)...
|
by: Ruby Tuesdays |
last post by:
in win32 installation... is it compiled with it or this is a missing
features? Thanks
|
by: Ian Griffiths |
last post by:
I have been given a schema, instances of which I'm required to be able to
consume and generate. I'd like to be able to manipulate these instances as
DataSets internally in my application. The schema defines the following
simpleType:
<xs:simpleType name="cs">
<xs:restriction base="xs:token">
<xs:pattern value="*"/>
</xs:restriction>
</xs:simpleType>
|
by: Doug Bailey |
last post by:
I am trying to create a coclass attribute for an outproc COM server
(i.e. an EXE). The project was created using the ATL Project wizard
using .NET2003.
The coclass is defined as follows:
#pragma once
#include "resource.h"
#include <comsvcs.h>
|
by: kitty |
last post by:
Can anybody help me out with how to use fnmatch.h to help with regular
expression use in c++ ?
Also does fnmatch.h work only in linux ?
Thankyou for all your help
| |
by: kepioo |
last post by:
Hi,
I have some files in a directory :
Results Log, 11;21AM, Apr 09 2006.txt
Results Log, 11;21AM, Apr 08 2006.txt
Results Log, 03;59AM, Apr 07 2006.txt
otherfile1.txt
otherfile2.txt
....
|
by: jmalone |
last post by:
I have a python script that I need to freeze on AIX 5.1 (customer has
AIX and does not want to install Python). The python script is pretty
simple (the only things it imports are sys and socket).
The README file in the Tools/freeze directory of the Python-2.4.4
distribution says the following (and many other things):
Previous versions of Freeze used a pretty simple-minded algorithm to
|
by: abcd |
last post by:
I am using fnmatch.fnmatch to find some files. The only problem I have
is that it only takes one pattern...so if I want to search using
multiple patterns I have to do something like....
patterns =
for p in patterns:
if fnmatch.fnmatch(some_file_name, p):
return True
|
by: Sreeraj |
last post by:
hi,
I am a beginner in Python. I wish to know how can i filter a list of
strings using wild characters.ie
Lets say i have list countries =
. I need only the list
of string starting with 'a'.
thank you
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |