Re: [Tutor] miniwiki 1.3 BETA bugs
Kirk Z Bailey wrote: RE leaves me totally confuzzzeddded. Yep, so confuised I'm having trouble spelling it. Sp this one line will replace both words and give a reliable result? Barnaby Scott wrote: [snip] No idea if it has anything to do with your problem, but it struck me that the iswikiword() function (and processword() which seems to be a helper for it) could be replaced with one line, and it would be reliable! def iswikiword(word): return bool(re.match('^([A-Z][a-z]+){2,}$', word)) Of course you need to import re, but that seems a small price to pay! HTH Barnaby Scott As far as I know this is 100% reliable - at least it works for me (www.waywood.co.uk/MonkeyWiki/). I suggest you test the function to your own satisfaction - feed it tricky 'possible' WikiWords, and see how it does! I know what you mean - RE syntax is an unruly beast to try and wrestle with, but I *so* glad I made the effort. I don't claim to be anything like an expert, but I now find it very useful indeed. Here's how the function's statement works in case you're interested: bool(re.match('^([A-Z][a-z]+){2,}$', word)) re.match() will look for a match for us, according to the RE given as the first argument, and the string you want to match against as the second ^ means we demand that the pattern matches from the beginning of the string to be tested - we don't want to say yes to anEmbeddedWikiWordLikeThis. (In fact because we are using re.match instead of re.search this is not strictly necessary, but makes it clearer) ([A-Z][a-z]+) means we want a group of letters, starting with a one in the range [A-Z] i.e. a capital, followed by [a-z]+ , meaning one or more lowercase letters ('one or more' is specified by the +). That whole pattern is parenthesised because we want the next element to refer to the whole thing {2,} means we want a match only if our preceding pattern (i.e. a capitalised word) occurs a minimum of 2 times in a row, and a maximum of - well, we don't want to specify a maximum, so we leave it out. (YouMightInFactWantToSpecifyTheMaximumNumberOfWordsThatAreAllowedToAppearInYourWikiLinksToStopPeopleDoingSillyThingsLikeThis). $ means we want a match only if the pattern reaches the end of the test string - i.e. we don't want to match a WordLikeThis62734. As for bool() - nothing to do with RE, but if a match occurs, the result returned by re.match() is a MatchObject instance, otherwise None. I have used bool() to convert these two possible results into True or False though I guess this is not strictly necessary - the truth testing would happen implicitly outside the function anyway. However it seems right to return a boolean if that's what the function's obvious intent is. HTH Barnaby Scott ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] miniwiki 1.3 BETA bugs
ok, when I have some time to do some coding I will work on trying this. AS is, it is pretty cleaned up, b utg making it less hairy and more definate in it's execution is a Great Good Thing(tm). If the project intrests you I will sip up the current version and leave it on my domain so you can find it. when it is on the4re I will post a link on the list. this may take 2 days, I am being rather busy right now. Barnaby Scott wrote: Kirk Z Bailey wrote: RE leaves me totally confuzzzeddded. Yep, so confuised I'm having trouble spelling it. Sp this one line will replace both words and give a reliable result? Barnaby Scott wrote: [snip] No idea if it has anything to do with your problem, but it struck me that the iswikiword() function (and processword() which seems to be a helper for it) could be replaced with one line, and it would be reliable! def iswikiword(word): return bool(re.match('^([A-Z][a-z]+){2,}$', word)) Of course you need to import re, but that seems a small price to pay! HTH Barnaby Scott As far as I know this is 100% reliable - at least it works for me (www.waywood.co.uk/MonkeyWiki/). I suggest you test the function to your own satisfaction - feed it tricky 'possible' WikiWords, and see how it does! I know what you mean - RE syntax is an unruly beast to try and wrestle with, but I *so* glad I made the effort. I don't claim to be anything like an expert, but I now find it very useful indeed. Here's how the function's statement works in case you're interested: bool(re.match('^([A-Z][a-z]+){2,}$', word)) re.match() will look for a match for us, according to the RE given as the first argument, and the string you want to match against as the second ^ means we demand that the pattern matches from the beginning of the string to be tested - we don't want to say yes to anEmbeddedWikiWordLikeThis. (In fact because we are using re.match instead of re.search this is not strictly necessary, but makes it clearer) ([A-Z][a-z]+) means we want a group of letters, starting with a one in the range [A-Z] i.e. a capital, followed by [a-z]+ , meaning one or more lowercase letters ('one or more' is specified by the +). That whole pattern is parenthesised because we want the next element to refer to the whole thing {2,} means we want a match only if our preceding pattern (i.e. a capitalised word) occurs a minimum of 2 times in a row, and a maximum of - well, we don't want to specify a maximum, so we leave it out. (YouMightInFactWantToSpecifyTheMaximumNumberOfWordsThatAreAllowedToAppearInYourWikiLinksToStopPeopleDoingSillyThingsLikeThis). $ means we want a match only if the pattern reaches the end of the test string - i.e. we don't want to match a WordLikeThis62734. As for bool() - nothing to do with RE, but if a match occurs, the result returned by re.match() is a MatchObject instance, otherwise None. I have used bool() to convert these two possible results into True or False though I guess this is not strictly necessary - the truth testing would happen implicitly outside the function anyway. However it seems right to return a boolean if that's what the function's obvious intent is. HTH Barnaby Scott -- Salute! -Kirk Bailey Think +-+ | BOX | +-+ knihT Fnord. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] miniwiki 1.3 BETA bugs
RE leaves me totally confuzzzeddded. Yep, so confuised I'm having trouble spelling it. Sp this one line will replace both words and give a reliable result? Barnaby Scott wrote: [snip] No idea if it has anything to do with your problem, but it struck me that the iswikiword() function (and processword() which seems to be a helper for it) could be replaced with one line, and it would be reliable! def iswikiword(word): return bool(re.match('^([A-Z][a-z]+){2,}$', word)) Of course you need to import re, but that seems a small price to pay! HTH Barnaby Scott -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] miniwiki 1.3 BETA bugs
ok, let's post this again. last time went into purgatory instead of the list. hmmm I am working on updating miniwiki. the current beta code has rendering problems with wikiwords and external sites under some circumstances. Here is a link to the latest code: http://www.tinylist.org/MW.txt Blessed Be! - Kirk Bailey Largo FL USA kniht +-+ http://www.mylemonadestand.biz/ - play the lemonade game! | BOX | http://www.tinylist-org/ Freedom software +-+ In HER Service- http://www.pinellasintergroupsociety.org/ think http://www.seaxtradusa.org/ - The Seax Wica Trad in the USA! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] miniwiki 1.3 BETA bugs
Kirk Z. Bailey wrote: ok, let's post this again. last time went into purgatory instead of the list. hmmm I am working on updating miniwiki. the current beta code has rendering problems with wikiwords and external sites under some circumstances. Here is a link to the latest code: http://www.tinylist.org/MW.txt Blessed Be! - Kirk Bailey Largo FL USA kniht +-+ http://www.mylemonadestand.biz/ - play the lemonade game! | BOX | http://www.tinylist-org/ Freedom software +-+ In HER Service- http://www.pinellasintergroupsociety.org/ think http://www.seaxtradusa.org/ - The Seax Wica Trad in the USA! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor No idea if it has anything to do with your problem, but it struck me that the iswikiword() function (and processword() which seems to be a helper for it) could be replaced with one line, and it would be reliable! def iswikiword(word): return bool(re.match('^([A-Z][a-z]+){2,}$', word)) Of course you need to import re, but that seems a small price to pay! HTH Barnaby Scott ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor