User Profile

Collapse

Profile Sidebar

Collapse
robin746
robin746
Last Activity: Aug 15 '07, 03:04 PM
Joined: Aug 9 '07
Location: Ireland
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • 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.
    See more | Go to post

    Leave a comment:


  • robin746
    replied to Getting the size of sourcecode
    I have just published a full Line Of Code Counter that you can adapt to your purpose.
    See more | Go to post

    Leave a comment:


  • robin746
    replied to Getting the size of sourcecode
    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
    ...
    See more | Go to post

    Leave a comment:


  • robin746
    replied to Initialize lists; here's why
    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.
    See more | Go to post

    Leave a comment:


  • robin746
    replied to Iterating over a file in python
    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)
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...