Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:23:52+00:00 2026-06-10T02:23:52+00:00

So say I have a retrieved directory name, LibX_00.03, and I retrieve the version

  • 0

So say I have a retrieved directory name, “LibX_00.03”, and I retrieve the version information of the directory with:

lib = "LibX_00.03"

version = lib[-5:]

After doing this I then want to compare this version number with others to assert the latest release of the library, the trouble with this being that is has to be in a numberic form for comparison and not a str.
Casting to int or float both do not work, as int will give a whole number, and float gives an innacurate conversion:

>>> float(version)
0.299999...

So how can I accurately preserve the version number while having it in a form where I make a comparison?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:23:53+00:00Added an answer on June 10, 2026 at 2:23 am
    >>> from distutils.version import StrictVersion
    >>> StrictVersion('00.03') > StrictVersion('00.10')
    False
    >>> StrictVersion('00.03') > StrictVersion('00.02')
    True
    

    Note this won’t work if you have '1.0b' as version string, for that use LooseVersion:

    >>> from distutils.version import LooseVersion
    >>> LooseVersion('1.2b') > LooseVersion('0.1')
    True
    >>> LooseVersion('1.2b') > LooseVersion('1.2c')
    False
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have this url: www.example.com/test.php?page=4 How do i retrieve the value of
Let's say I have retrieved a System.Type object using reflection and want to use
Let's say I have a string that I retrieve from a DB like: Lorem
Lest say that we have several pages that retrieve items from the same EntitySet.
Lets say have this immutable record type: public class Record { public Record(int x,
Say I have a Telerik MVC Grid, AJAX bound and I want to put
Lets say you have a website, that uses a function to retrieve data from
Let's just say for the purpose of this question, we have a blog. Now,
Say I have a select box eg <div data-bind='visible: someProp'> <select class=selectSubWidgets data-bind='options: subWidgets,optionsText:
Say we have deep hashes like: b = {1 => {2 => {} },

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.