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 540071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:12:07+00:00 2026-05-13T10:12:07+00:00

I have code to read in the version number from a make file. VERSION_ID=map(int,re.match(VERSION_ID\s*=\s*(\S+),open(version.mk).read()).group(1).split(.))

  • 0

I have code to read in the version number from a make file.

VERSION_ID=map(int,re.match("VERSION_ID\s*=\s*(\S+)",open("version.mk").read()).group(1).split("."))

This code takes VERSION_ID=0.0.2 and stores it as [0, 0, 2].

Is there any way I can increment this number by one and write the new version number into the version.mk file with the variable VERSION_ID.

Thanks

I have tried the same statement with write() instead of read() but I am getting an error saying that I can not write a list. I have also tried to write it as a string but am getting a bad file descriptor message.

s = str(VERSION_ID)

VERSION_ID=map(int,re.search("VERSION_ID\s*=\s*(\S+)",open("version.mk").write(s)).group(1).split("."))

I know this is rubbish, I just can’t seem to find what to do here in the online docs.

I have also tried the pickle module to no avail. Maybe I’d be able to write a pickled list instead and then unpickle it. Or I was thinking I could just write over the whole line altogether.

I’ve tried to do anther approach, Ihave tried to get list to be entered as a string. I have tried this but I am not sure if it will work.

for x in VERSION_ID:
    "VERSION_ID={0}.{1}.{2}.format(x)
  • 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-05-13T10:12:08+00:00Added an answer on May 13, 2026 at 10:12 am

    perhpas something like this (you should also check for errors and that)

    #! /usr/bin/python
    
    import re
    
    fn = "version.mk"
    omk = open(fn).readlines()
    nmk = open(fn, "w")
    r = re.compile(r'(VERSION_ID\s*=\s*)(\S+)')
    
    for l in omk:
        m1 = r.match(l)
        if m1:
            VERSION_ID=map(int,m1.group(2).split("."))
            VERSION_ID[2]+=1 # increment version
            l = r.sub(r'\g<1>' + '.'.join(['%s' % (v) for v in VERSION_ID]), l)
        nmk.write(l)
    nmk.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 371k
  • Answers 371k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to add "." to your path. Some people… May 14, 2026 at 6:56 pm
  • Editorial Team
    Editorial Team added an answer Declare them as const Objects in the static class -… May 14, 2026 at 6:56 pm
  • Editorial Team
    Editorial Team added an answer There's no out-of-the-box facility to do this, no. However, if… May 14, 2026 at 6:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.