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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:52:22+00:00 2026-05-23T21:52:22+00:00

I have a python file in the location ‘lib/lib_add_participant.py’.And I declared a class in

  • 0

I have a python file in the location ‘lib/lib_add_participant.py’.And I declared a class in the file.

Now I want to call the class functions from the file call_participant.py.

I tried this code from lib/lib_add_participant.py import LibAddParticipant

Its not worked.Please correct me(I am coming from Ruby).

  • 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-23T21:52:23+00:00Added an answer on May 23, 2026 at 9:52 pm

    If your file structure is as follows:

    myproject/
        __init__.py
        call_participant.py
        lib/
            __init__.py
            lib_add_participant.py
    

    In this case, your __init__.py files can be empty, if you like (or they can define any number of things – see this fine answer from Alex Martelli for more details.

    then you can add it by using

    from .lib.lib_add_participant import LibAddParticipant
    

    However, if call_participant.py is your end script, then this tactic will not work, because you “can’t do a relative import in a non-package”, as the interpreter will tell you. In that case, your best bet (in my opinion, at least) is to make lib into a package in your python path (either in your site-packages directory, or in a path referred to by your pythonpath environment variable).

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

Sidebar

Related Questions

I have a Python file with as content: import re import urllib class A(object):
I have a python program/file that I want to run repeatedly and calculate the
I have a python class which reads a config file using ConfigParser: Config file:
I have a python file testHTTPAuth.py which uses module deliciousapi and is kept in
I have created a Python file to generate a Mandelbrot set image. The original
Let's assume I have a main script, main.py, that imports another python file with
I have a python application that relies on a file that is downloaded by
I have a Python script that reads through a text csv file and creates
I have a small python script which i use everyday......it basically reads a file
I'm processing a UTF-8 file in Python, and have used simplejson to load it

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.