User Profile
Collapse
-
It is helpful to wrap os.walk to create a custom generator. My version of this was published in the Python Cookbook, a must-have text for anyone working in the language. A simpler version is on my programming blog if you want a quick demonstration. -
I have just published a full Line Of Code Counter that you can adapt to your purpose.Leave a comment:
-
Please clarify. If you have read the page into a variable, it is (likely) already a string. The str() function converts to a string but I do not think that is what you want.
What error does your module spit back? Wrap the code you have in a try/except block specifying this error, and then do what you want when it happens. For example, if the error is BadSillyError, do this:
Code:try: # code to run
Leave a comment:
-
Your testing only five times? I doubt that is statistically sound. What happens when you try 1000?
In any case trying to micromanage performance like this is really the wrong way to programme. First, find if your app is not fast enough, then profile, then fix the bottleneck.
Remember the first rule of optimisation: Don't.Leave a comment:
-
Or even:
Code:out = [] with open(fileName) as f: for line in f: if line.startswith('>'): continue out.append(line) with open(newFileName, 'w') as f: f.writelines(out)
Leave a comment:
No activity results to display
Show More
Leave a comment: