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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:32:48+00:00 2026-05-23T14:32:48+00:00

There are two files in the scope of this problem, let’s call them file1.py

  • 0

There are two files in the scope of this problem, let’s call them file1.py and file2.py.

I’ve imported file2.py into file1.py.

I instantiate a class in file1.py and I’d like to access it in file2.py. I’ve tried referencing the object directly (just the class name) but that doesn’t work. How can I reference the object? I don’t want to move this to the same file, it’d make it messy.

Is there a non-hackish way to do this? If not, have I implemented a faulty design?

  • 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-23T14:32:49+00:00Added an answer on May 23, 2026 at 2:32 pm

    You need to pass the class from somewhere in File1.py to one of the classes in file.2.

    You can simply pass a reference to the class when you invoke the method in file2.py where you need to use it.

    Or you can write a “Set….” Method and pass the reference and store it in one of the classes in file2.py.

    You could also make it a global static variable — but you would get refused entry to the better coding clubs if you did this.

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

Sidebar

Related Questions

I have two XML files. They are similar, but there are two nodes of
Say I have two files where there is one number per line File 1
I have two files which both contain a list of words. Is there an
Is there any fast algorithm that allows to compare two files (for verification purpose)
Is there any built-in, add-in solution for visual studio to compare two files and
I'm using doxygen for commenting code. There is, for example, two files: test1.cpp :
There seems to be two major conventions for organizing project files and then many
Is there any way to list all the files that have changed between two
POSIX environments provide at least two ways of accessing files. There's the standard system
Two questions, really: Is there a standard/convention regarding the placement on configuration files? For

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.