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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:40:16+00:00 2026-05-24T10:40:16+00:00

I have write a python library app(which contains several *.py files). And several of

  • 0

I have write a python library app(which contains several *.py files). And several of my python projects need to reuse the code in the library app. What’s the recommended best practice for reusing python code? Currently I have thought out three options:

  1. Copy and paste. This is far away from best practice. It violates the
    DRY principle.(Don’t repeat yourself.)
  2. Add the folder of the library app to the environment variable PYTHONPATH: export PYTHONPATH=/path/to/library/app. Then every projects on the same computer can reference the code in the library app.
  3. And the folder of the library app to sys.path in python code: sys.path.append('/path/to/library/app')

Among the three options above which one do you prefer? What advantage does it have compared to the other two options? Do you have any other better options? It is much appreciated that if some one with years of python development experiences could answer this question.

  • 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-24T10:40:17+00:00Added an answer on May 24, 2026 at 10:40 am

    Allow me to propose a fourth alternative: take the time to learn how to package your library and install it in your site-packages; it’s easier than one may think and I’m convinced it’s time well spent. This is a very good starting point: https://packaging.python.org/en/latest/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to python and bencoding. I need to read and write torrent files
I have to write a reliable, totally-ordered multicast system from scratch in Python. I
I have a Python list, say l = [1,5,8] I want to write a
I have to write something in vbscript that need to use a unique set.
I have to write a program that read from a file that contains the
I have started to write a Python 3.x client application. The server application exists
I have one doubt. I need to write site on embedded system ( memory
I have this code in a C application that's embedding Python (2.7.1): { PyObject
I have a Python script I recently wrote that I call using the command
How can I determine if I have write permission on a remote machine in

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.