472,353 Members | 1,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

More List Comparison Help

I have taken into advice what was mentioned earlier, but I have run
into a snag in which I am getting the wrong output from my class.
python matchlist.py ./test ./test/list.txt
['list.txt', 'test1.txt', 'test2.txt']
['', '/', 't', 'e', 's', 't']

The first line of output correctly displays the list of file names in
the argv[1] directory.
The second line of output correctly displays the set list from
readlines on list.txt.
The third line of out put should be the same as the 1st line minus the
extenxions in the file names.

Here is the code:

import os
from sys import argv

class MatchList:
def __init__(self, dirList, fileList):
self.dirList = os.listdir(dirList)
self.fileList = set(open(fileList, 'r').readlines())
self.matchList = []
self.retList = []
self.rut = []
def match(self):
for item in dirList:
rut = os.path.splitext(item)[0]
print self.matchList
def testPrint(self):
print self.dirList
print self.fileList

if __name__ == '__main__':
if len(argv) == 3:
dirList = argv[1]
fileListName = argv[2]
match = MatchList(dirList, fileListName)

What I want to happen is produce a list of the filenames minus the
extensions so that I can set that list. Once that list is set, I can
subtract the set list from the readlines function and then use the
difference list to determine what files are missing form the directory.

Thanks in advance:)

P.S. Is there a special way to include code in my postings so that it
looks different from the rest of the text in the posting?

Aug 21 '06 #1
1 1394
Nevermind. I found my own error. I referenced the input values
instead of the class object self. That is what I get for staring at
the code too long.



Aug 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Craig Keightley | last post by:
is it possible to compare acomma separated list aginst another eg comma list 1 => 1,2,3,4,5 comma list 2 => 3,5 can you check that 3 is in both,...
by: Xah Lee | last post by:
here's another interesting algorithmic exercise, again from part of a larger program in the previous series. Here's the original Perl...
by: Balaji. M. | last post by:
Hi All, Help me to sort out the contents in the list box. The list box contains data elements like <first name> + <middle name> + <last name>...
by: Antoon Pardon | last post by:
I was wondering how people would feel if the cmp function and the __cmp__ method would be a bit more generalised. The problem now is that the cmp...
by: Rajesh | last post by:
Question :An element in a sorted list can be found in O(log n) time via binary search. But suppose I rotate the sorted list at some pivot unknown...
by: akameswaran | last post by:
Disclaimer - I recognize this is not a practical exercise. There are many implementations around that would do the job better, more efficiently...
by: ASP Developer | last post by:
I have a generic list of objects. These objects have a text field that contains a letter for the first character and numbers for the next three....
by: Sheldon | last post by:
Hi, I am trying to understand linked lists and the different ways to write a linked list and double linked list. I have been trying to get this...
by: Godzilla | last post by:
Hello, I'm trying to find a way to convert an integer (8-bits long for starters) and converting them to a list, e.g.: num = 255 numList = ...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.