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

  • SEARCH
  • Home
  • 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 9215069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:07:08+00:00 2026-06-18T02:07:08+00:00

I was using python 2.6 for a script, but for requirement limitations I have

  • 0

I was using python 2.6 for a script, but for requirement limitations I have to downgrade my script to python 2.5, how can I get the relative path using python 2.5?

I was previously using:

os.path.relpath(path[, start])

But since this is new from 2.6 I can’t use it anymore.

Thanks and regards!

  • 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-18T02:07:10+00:00Added an answer on June 18, 2026 at 2:07 am

    Try Relative paths in Python it should have valuable information to you.

    >>> import sys
    >>> import os.path
    >>> sys.path[0]
    'C:\\Python25\\Lib\\idlelib'
    >>> os.path.relpath(sys.path[0], "path_to_libs") # if you have python 2.6
    >>> os.path.join(sys.path[0], "path_to_libs")
    'C:\\Python25\\Lib\\idlelib\\path_to_libs'
    

    EDIT: Found something more http://www.saltycrane.com/blog/2010/03/ospathrelpath-source-code-python-25/
    It is a re-implementation by James Gardner:

    from posixpath import curdir, sep, pardir, join
    
    def relpath(path, start=curdir):
        """Return a relative version of a path"""
        if not path:
            raise ValueError("no path specified")
        start_list = posixpath.abspath(start).split(sep)
        path_list = posixpath.abspath(path).split(sep)
        # Work out how much of the filepath is shared by start and path.
        i = len(posixpath.commonprefix([start_list, path_list]))
        rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
        if not rel_list:
            return curdir
        return join(*rel_list)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python script using the boto library on ec2 instance which is
I have a batch file containing a python script using the Output template> %(NAME)s
I have a Python script that is using some closed-box Python functions (i.e. I
I have a little python script that I am using to download a whole
I have a requirement where using Python I need to write into excel cell
I am using Python 2.7 on Windows XP. I have a simple python script
I have a python script which I call using python main.py on my terminal.
I have a Python script that writes to a MySQL database using mysql-python .
I've been using python for years, but I have little experience with python web
I have a Python script adapted from Downloading MMS emails sent to Gmail using

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.