Saturday, March 28, 2009

Metal Gas Cans For Sale In Canada

dependencies in Python - Python Dependencies getClass

Here we are on the second piece of code. Today we see the getClass function that reads a line of code (from a file. Py) and identifies the class defined:
 
final getClass (line): # Check if the first five letters of the line are the same 'class' if line [: 5] == "class": # Search the brackets to see where the class name ends end = line.find ("(") # Check if you have found the parentheses if end ==- 1: # If the search does not find the brackets ':' end = line.find (":") # Returns class name that stands between # 6 and end the character return line [6: end] # Returns -1 if not found the word 'class' else: return -1
all for today to the next. For the functions already seen click below:
TrovaNelFile

0 comments:

Post a Comment