[Tutor] wiki madness

Sean 'Shaleh' Perry shalehperry at comcast.net
Fri Aug 8 00:31:56 EDT 2003


On Thursday 07 August 2003 20:30, Kirk Bailey wrote:
> Improving. Wrong,but better.
>

comments:

* no need to define caps, just use string.ascii_uppercase (and lowercase is 
there too)

* why not define ishyperlink() using string.startswith()?
or perhaps something from the urllib module?

* wordsplit() doesn't actually split, more like strips.  You could write that 
function as:

for char in word:
    if char not in punctuation:
        newword += char # or 1.5 style newword = newword + char
    else:
        extras = extras + char
    return words, extras

* style comment.  I like to use the formatting operator instead of lots of 
string math.

link = '<a href="%s">%s</a>' % (word, word) # instead of
link = '<a href="' + word + '">' + word + '</a>'

while discussing style, this is python, feel free to use some whitespace.  
Your code reads like a bourne again shell coder.

* parseline() is begging for a list and a loop.  Also, you are not parsing the 
line.  parsing is breaking down into tokens and performing actions with the 
tokens.

* marking main() with the python idiom of:

if __name__ == '__main__':
   # code

would be a good best practice to follow.  Also lets you load any of yourt 
python apps as modules for other python apps.

Sorry, did not run it to help you debug it.  Just wanted to pass on some style 
ideas for the other readers.




More information about the Tutor mailing list