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
#4
(May-24-2023, 06:11 AM)Gribouillis Wrote:
(May-24-2023, 01:10 AM)MeghansUncle2 Wrote: I know it sounds confusing so I'll try to illustrate the question
Please post a complete example. As it is, the code is not understandable, for example
self.myobj = myclass
 
 
self.myobj(parameters)
cannot run because myclass has not been previously defined and parameters has not been defined, and also self has not been defined. Try to write code that we can run.

This is not actual code. It is an abstract form of code to illustrate my question.

The question is, can i use an object created within another object outside of that other object. in my example, can i access object "B" outside of object "A"

Main Code
Self.A = Aclass

Self.A .somemethod
...
A class
class Aclass(object):

def somemethod()
       self.B = Bclass
I know I left out a lot and this code will not stand on its own. I am asking is there a way to reference the B object from the main code (outside of the A object)?
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to capitalize letter in list object Python iwonkawa 4 241 May-29-2024, 04:29 PM
Last Post: DeaD_EyE
  I am getting this TypeError: 'TreasureMap' object is not subscriptable. makilakos 2 259 May-25-2024, 07:58 PM
Last Post: deanhystad
  Printing out incidence values for Class Object SquderDragon 3 440 Apr-01-2024, 07:52 AM
Last Post: SquderDragon
  This result object does not return rows. It has been closed automatically dawid294 6 1,528 Mar-30-2024, 03:08 AM
Last Post: NolaCuriel
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 611 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  How can I pause only one object? actualpy 1 433 Feb-01-2024, 07:43 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 657 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Question Chain object that have parent child relation.. SpongeB0B 10 1,286 Dec-12-2023, 01:01 PM
Last Post: Gribouillis
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 911 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 2,155 Nov-07-2023, 09:49 AM
Last Post: buran

Forum Jump:

User Panel Messages

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