-1

Possible Duplicate:
comparing contents of two files using python

I have a file name globalexclusionlist.txt and i have contents in it like

      #include <stdio.h>
      #include <iostream>
      import subprocess
      import java.sql.*;import java.io.*;
      ruby library
      show tables; 

      ......and many more

I have another file named libraries.txt and the contents of this file are

     import mymodule
     import empmodule,os
     import subprocess
     import java.sql.*
     #include <stdio.h>
     #include <iostream>
     import datetime,logging,re
     import java.io.*;
     .......and many more

My question is that from python how to know that the contents which are in exclusionlist.txt is also present in libraries.txt since here it is jumbled up..

     f = open('globalexclusionlist.txt', 'r')
     f.read()

     f1= open('libraries.txt', 'r')
     f1.read()

    if (//Is contents of f1 present in f2):
         print libraries found
    else:
         print not found

    f.close()
    f1.close() 
5
  • possibly duplicate, that post was answered for only comparing python imports and i want to do it for all.. like the mentioned above.. Commented Jun 4, 2011 at 7:22
  • So why don't you modify the accepted answer to your other question? And ask a specific question if you have a problem, rather than expecting people to write code for you? Commented Jun 4, 2011 at 7:36
  • I have accepted the answer..and also have wrote a comment Commented Jun 4, 2011 at 7:52
  • I'm not suggesting You modify the question, rather that you actually make some attempt at coding this yourself, using te previous answer as a base. This is a site for programmers, not for people wanting software to be written for them! Commented Jun 4, 2011 at 8:37
  • @Johnsyweb: I know that, but the point i am making is that the previous question was not appropriate which i agree and that is why i asked another question.And to your point i didnt ask any software to be written i just want to know the methods.Please let me close this question if it bothers u so much..And i do not want non technical suggestions on this site..Any way thanks Commented Jun 4, 2011 at 15:00

1 Answer 1

0

Check out difflib

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.