anlutro / botologist

Plugin-driven Python3 IRC
MIT License
5 stars 5 forks source link

conversion #32

Closed FredG71 closed 9 years ago

FredG71 commented 9 years ago

There's probably a better way to handle that, but using duckduckgo either gave incorrect results or simply didn't work, besides using duckduckgo to handle that was probably not needed imo considering that the conversion constants never actually change.

anlutro commented 9 years ago

Using static values and multiplication/division to handle conversion may not be not a bad idea in and of itself, but maintaining such a table could quickly turn out to be a mess. Duckduckgo also gives access to more than just lengths, it can try and guess abbreviations/multiple spellings etc.

anlutro commented 9 years ago

A better way of extracting "tokens" - each group denoted by () can be captured by using match.group(N) where N is the number of the match. For example:

>>> match = re.search(r'([a-z]+) ([A-Z]+)', 'abc ABC')
>>> match.group(1)
'abc'
>>> match.group(2)
'ABC'