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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:39:12+00:00 2026-06-17T23:39:12+00:00

I have four python scripts with below code: main.py from new import Name1 from

  • 0

I have four python scripts with below code:

main.py

from new import Name1
from new2 import Name2

class Details:

    def __init__(self, id=0, vuse=True):
        assert(id > 0)
        self.id = id
        self.vuse = vuse

    def Main(self):
        try:
            self.dir = "/value/"
            ti = Name1(id = self.id, dir = self.dir)
            name = ti.getDay()
            print name
        except Exception, e:
            print "Failed with %s" % e

if __name__ == "__main__":
    at = Details(id = '1', vuse=True)
    at.Main()

new.py

class Name1:

    def __init__(self,id,dir=''):
        self.id = id
        self.dir = dir

    def getDay(self):
        try:
            if id == 1:
                self.day = "monday"
                print "Name %s" % self.day
                return self.day
            else:
                self.day = "Another"
                print "Day %s" % self.day
                return self.day
        except Exception, e:
            print "ERROR : %s" % e

new2.py

from find import Find
from main import Details

class Name2:

    def getitems(self):
            self.id = "// This value i want from main.py or new.py script"
        at = Find(id = self.id )
        val = at.value()
        print val

if __name__ == "__main__":
    a = Name2()
    a.getitems()

find.py

class Find:

    def __init__(self, id):
        self.id = id

    def value(self):
        if self.id == 1:
            print "Right value"
            ##// Do some operation with id//

        else:
            print "invalid"

My problem is how can i access the id value in new2.py…
if I will take the value from main.py, for calling the class i need to pass the id value which new2.py does not have. The same thing for new.py also, i need id to create an object of a class.

  • 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-17T23:39:14+00:00Added an answer on June 17, 2026 at 11:39 pm

    It’s not clear how your program is supposed to work, but you can initialize id in an instance of Name2 when you create it:

    def Main(self):
        self.dir = "/value/"
        ti = Name1(self.id, self.dir)
        ti_2 = Name2(self.id)
    
    class Name2:
        def __init__(self, id):
            self.id = id
    

    or pass it to getitems as an argument:

    def Main(self):
        self.dir = "/value/"
        ti = Name1(self.id, self.dir)
        ti_2 = Name2()
        ti_2.getitems(self.id)
    
    class Name2:
        def getitems(self, id):
            self.id = id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have a Python script that pulls in data from many sources (databases, files,
In Python I have four strings that include the formatting of a list: line1
I have a list or lists in python similar to the following: [ ['name1',value2],
I have declared four variables [a=1,b=2,c=3,d=0] in python and swapping them in one line
I have a python dictionary such as { 'FOUR': [['emit', 'build', 'simulate'], 'TestFour', 2],
I have a Python 3 project where I'm dynamically importing modules from disk, using
Let's say that I have a class Suit and four subclasses of suit: Heart,
I am brand new to Python and have been working with it for a

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.