473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Can anyone Pythonize this lexical algorithm?

I am writing a package manager and stuck unable to write the version
sorting function the algorithm is here http://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!
Oct 9 '08 #1
2 1613
On Oct 9, 7:29*am, ShashiGowda <connect2sha...@gmail.comwrote:
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 <connect2sha...@gmail.comwrote:
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

Oct 9 '08 #2
ShashiGowda wrote:
I am writing a package manager and stuck unable to write the version
sorting function the algorithm is here http://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!
Assuming you want 10.1 to sort after 9.8 and 1.10 after 1.9, you want to
compare tuples or lists of ints.

Oct 9 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Collin VanDyck | last post by:
Hello! I have set up a pluggable SAX transformation pipeline which is made up of individual nodes that transform the source XML, and for the most part it works well. Each node in the pipeline...
4
by: bariole | last post by:
Hi I am trying to make lexical analysis of some simplified html code with flex tool. However that kind of work is new to me and I don't know where to start. I have searched a web but I didn't...
13
by: Lucas Zimmerman | last post by:
Is there any Lex code available that describes how to scan C programs? I'd like to read someting related to this. One of my doubs is how C deals with ambiguities, for example, `a = x/*p;' or `a =...
18
by: jslowery | last post by:
I am not completely knowledgable about the status of lexical scoping in Python, but it was my understanding that this was added in a long time ago around python2.1-python2.2 I am using python2.4...
2
by: Frank-René Schäfer | last post by:
penSource Project 'Quex': http://quex.sf.net Last weekend, the lexical analyser generator 'Quex' has been released on SourceForge. Quex provides advanced features for mode definitions and...
6
by: enaeher | last post by:
I would expect this code: globalFnArray = ; for (var i = 0; i < 5; i++) { globalFnArray.push (function () { alert (i) }); } for (var j = 0; j < 5; j++) { globalFnArray(); } to alert 0, 1, 2,...
14
by: Khookie | last post by:
Woah... is it just me or do C programmers don't bother talking about how cool C can be (compared to Lisp, Haskell, etc.) - functionally speaking? // Lexical scoping - via nested functions...
2
by: moon123 | last post by:
We have to program it in two parts: the lexical analyzer and the syntax analyzer plus semantic.The lexical analyzer should recognize the token using DFA and return the token and the value. The syntax...
3
by: globalrev | last post by:
i cant figure outif python has lexical or general scope. it seems functions have lexical scope but with some restrictions and some non-function scopes are dynamic?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.