suggestions for VIN parsing

Vincent Davis vincent at vincentdavis.net
Mon Dec 29 11:58:16 EST 2014


On Sun, Dec 28, 2014 at 11:50 PM, Rick Johnson <rantingrickjohnson at gmail.com
> wrote:

> 3. I see that you are utilizing regexps to aid in the logic,
> and although i agree that regexps are overkill for this
> problem (since it could "technically" be solved with string
> methods) if *I* had to solve this problem, i would use the
> power of regexps -- although i would use them more wisely ;-)
>
> I have not studied the data thoroughly, but just by "grazing
> over" the code you posted i can see a few distinct patterns
> that emerge from the VIN data-set. Here is a description of
> the patterns:
>
>     "\d+n"
>     "\d+na"
>     "d\d+"
>     "du\d+"
>
> and the last pattern being all digits:
>
>     "\d+"
>
> Even though your "verbose-run-on-conditional" would most
> likely execute faster, i prefer to write code (when
> performance is not mission critical!) in the most readable
> and maintainable fashion. And in order to achieve that goal,
> you always want to keep the main logic as succinct as
> possible whist encapsulating the difficult bits in "suitably
> abstracted structures".
>

​Rick,
Thanks for your suggestions, I was just starting version2 and wanted to do
something like you suggest.
Another question. I what to change the logic so that rather than return THE
match it return all matches. I want to do this for 2 reasons, 1, it would
act as a kinda test, If I only expect one match and I get more than I
likely have a problem, 2, I found a more extensive (maybe better) list of
frame numbers <http://www.britishonly.com/tech/joust/techtiptriumphmf.htm>,
I could see some overlapping although I have not looked real close yet.



Vincent Davis
720-301-3003
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141229/fe3c183d/attachment.html>


More information about the Python-list mailing list