Python Forum
Possible to create an object inside another object that is visible outside that objec
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possible to create an object inside another object that is visible outside that objec
#18
(May-25-2023, 01:29 PM)deanhystad Wrote: It is best if you can write a working example that displays the problem you are trying to solve. I know I get confused about a question that has code that looks like Python but clearly is not Python. You are trying to ask a question in a language you don't understand, and the language barrier is a more difficult puzzle than the question.

I have a class that makes an object. I want to get that object from outside the class
class A:
    def __init__(self):
        self.thing = Thing()

a = A()
# outside_thing = ?
If you cannot write a snippet like that, it is probably better to just go with text.

I have a class (call it "A") that makes an object (call it "thing"). I want to access the "thing" from outside an instance of the class

If you don't know enough to ask a question like that, take it as an indication that you need to spend some time learning about classes and objects. Ask a question like this:

I am just getting started learning to write my own Python classes. Can you recommend a good resource?

After study you will know what classes, instances and attributes are, and know enough of language that there won't be a language barrier in asking your question. Of course, after some study you'll probably know the answer to your question.

As you well know, the practical application of concepts learned in a book is something that takes some time and practice. Imagine that someone (insert my name here) has done so and still struggles with those concepts so he asks questions that are born of that inexperience and lack of understanding. Now imagine answering a question from such a person with "Go learn the language". It's a little frustrating.
Reply


Messages In This Thread
RE: Possible to create an object inside another object that is visible outside that objec - by MeghansUncle2 - May-25-2023, 02:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Printing out incidence values for Class Object SquderDragon 3 341 Apr-01-2024, 07:52 AM
Last Post: SquderDragon
  This result object does not return rows. It has been closed automatically dawid294 6 1,256 Mar-30-2024, 03:08 AM
Last Post: NolaCuriel
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 475 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  How can I pause only one object? actualpy 1 404 Feb-01-2024, 07:43 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 583 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Question Chain object that have parent child relation.. SpongeB0B 10 1,166 Dec-12-2023, 01:01 PM
Last Post: Gribouillis
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 799 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,926 Nov-07-2023, 09:49 AM
Last Post: buran
  TypeError: 'NoneType' object is not callable akbarza 4 1,106 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,491 Aug-23-2023, 06:21 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020