Monday, March 23, 2009

Green And Pink On Tv Screen

1 - Find the

Now began a series of posts concerning the dependencies in python. In practice, we will interpret the code needed to build a python file and the dependencies between files in your program.

The first thing to do is to identify the classes and functions found in different files. To do this we need three functions:

TrovaNelFile (filename, string)
getClass (line)
GetFunction (line)

TrovaNelFile: look for a file within a given text string and returns the rows where found the string

 
final TrovaNelFile (filename, string): # Open the file f = open (filename, "r") # reads all lines f.readlines lines = () # Initialize a new list # (required to do append ()) Occur = [] # Do the loop on lines * f or in the range ( len (lines)): # Check if string is # in the line read if string in lines [i]: # If you add the line number occur.append (i) # Close the file (it's always good to do) f.close () # returns the list of rows # string containing return Occur

* You could do also: < …for line in lines:…> however, lost count of the number of auto row.

all for today, we'll see in the next post the other two functions.

0 comments:

Post a Comment