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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:36:43+00:00 2026-06-13T13:36:43+00:00

Suppose I use some 3rd party module that depends on code from another one:

  • 0

Suppose I use some 3rd party module that depends on code from another one:

# third_party.py
from package import fun, A

class B(A):
    def foo(self):
        self.do()
        self.some()
        self.stuff()
        return fun(self)

And then I want to inherit this class in my code to change functionality:

# my_code.py

from third_party import B

# from third_party import fun?
# from package import fun?

class C(B):
    def foo(self):
        return fun(self)

What is better: from package import fun or from third_party import fun to get access to fun?

I like second variant since I may do not bother with actual paths and import all dependences from third_party package, but has this way any drawbacks? Is this a good or bad practice?

Thanks!

  • 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-13T13:36:44+00:00Added an answer on June 13, 2026 at 1:36 pm

    I dont’t think that importing a function/class from a third party package is a bad practice, it may even has some benefits (e.g: If you want to monkey patch a package, or need to be sure, that something is set up correctly).

    It even may be necessary to support a variety of setups. Consider the ElementTree API, which is differently available on specific Python versions and may even be provided from third party libraries (taken from here):

    # somepackage.py
    
    try:
      from lxml import etree
      print("running with lxml.etree")
    except ImportError:
      try:
        # Python 2.5
        import xml.etree.cElementTree as etree
        print("running with cElementTree on Python 2.5+")
      except ImportError:
        try:
          # Python 2.5
          import xml.etree.ElementTree as etree
          print("running with ElementTree on Python 2.5+")
        except ImportError:
          try:
            # normal cElementTree install
            import cElementTree as etree
            print("running with cElementTree")
          except ImportError:
            try:
              # normal ElementTree install
              import elementtree.ElementTree as etree
              print("running with ElementTree")
            except ImportError:
              print("Failed to import ElementTree from any known place")
    

    Now, it is guranteed that somepackage contains a working etree implementation, even on different Python installations and your package serves as an abstraction.

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

Sidebar

Related Questions

Let's suppose I have a string that contains 7.2769482308e+01 (this number came from 3rd
Suppose I am going to use some library that is installable through autotools in
Suppose both parent and child use one pipe for writing and reading means when
Suppose I'm designing a robot that can pickup various tools and use them. I
Suppose I have a program that initializes a global variable for use by threads,
I'm using a 3rd party app that uses regex to searches html documents, in
I have a 3rd party JavaScript application that declares several global functions and needs
I would like to use some build parameters from Project 1 in Project 2.
Suppose i want to use some standard set function so is it good for
Suppose there's a set of class Map1,Map2,Map3,... all extended from BaseMap, and I use

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.