One thing I noticed with that code was the size of your function, and excessive 
comments. It reminds me of my bubble_sort.c program in school/college - 
everything plonked into 'main'.

Try writing it like this:

1. #!/usr/bin/python or #!/usr/bin/env python

The leading #! is read by the kernel when it has to start the interpreter 
(exec), so don't stick your comment in there.

2. Try to align the imports so they look pretty

3. Don't use whacking big functions and then stick endless explanatory comments
Use the function name as a comment instead - divide your program up into little 
tasks. Try to make the stuff generic - def url_extract(content, pattern): 

def extract_url

def extract_title

def tk_init

Use
#-------------------------------------------------------------------
to demarcate sections, very common functions go into a utility-library,
not so common functions at the section at start of the file, and so on..

4. Don't skimp on the sys.exit() or def debug (which should be in your 
utilities lib)

5. Don't do :x = foo('.................................')
instead:
var_name = '..........................' # make it global
x = foo(var_name)

6. To build a string do:

param1 = xyz1 + xyz2
x = foo(param1)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to