On Oct 9, 7:29 am, ShashiGowda <[EMAIL PROTECTED]> wrote: > I am writing a package manager and stuck unable to write the version > sorting function the algorithm is > herehttp://www.linux.gr/cgi-bin/man/man2html?deb-version+5 > and all other info is also in it please tell me how to do lexical > comparision in python it'll be cool if you just write the code!
On Oct 9, 7:29 am, ShashiGowda <[EMAIL PROTECTED]> wrote: > I am writing a package manager and stuck unable to write the version > sorting function the algorithm is > herehttp://www.linux.gr/cgi-bin/man/man2html?deb-version+5 > and all other info is also in it please tell me how to do lexical > comparision in python it'll be cool if you just write the code! Step 1. Define a class, call it something like PackageVersion, with an __init__ method that takes an string containing the version string. In the body of __init__, use regular expressions, pyparsing, str methods, whatever, to break up the version into the individual fields. Step 2. Implement a __cmp__ method on PackageVersion that performs the desired version comparison logic. Take a crack at writing some code, and come back with specific questions. I doubt your hopes for coolness will be met. -- Paul -- http://mail.python.org/mailman/listinfo/python-list