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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:01:28+00:00 2026-05-15T21:01:28+00:00

Hey everyone, my problem is that im trying to figure out how to get

  • 0

Hey everyone, my problem is that im trying to figure out how to get a class INSIDE another class.

What I am doing is I have a class for an Airplane with all its statistics as to how fast it can fly, how far it can go, fuel consumption, and so on. Then I have a Flight Class which is all the details about the flight: Distance, starting location and time, ending location and time, duration, and so on.

But I realized that each airplane has multiple flights, so why not put all the flight data into the airplane class? Although how do i put a class INTO another class so i can call something like this:

Player1.Airplane5.Flight6.duration = 5 hours

Ive somewhat done it with the airplane class, but when i go to save the information (listing everything out into a text document), all it gives me is the Hex location of the data and not the actual strings.

class Player (object):#Player Class to define variables
    '''Player class to define variables'''

    def __init__ (self, stock = 0, bank = 200000, fuel = 0, total_flights = 0, total_pax = 0):
        self.stock = stock
        self.bank = bank
        self.fuel = fuel
        self.total_flights = total_flights
        self.total_pax = total_pax
        self.Airplanes = Airplanes
        self.flight_list = flight_list

Is there a way to put a class inside a class? or will i need to make one super Player class which handles all the information which im using other classes for?

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

    I think you are confusing objects and classes. A class inside a class looks like this:

    class Foo(object):
        class Bar(object):
            pass
    
    >>> foo = Foo()
    >>> bar = Foo.Bar()
    

    But it doesn’t look to me like that’s what you want. Perhaps you are after a simple containment hierarchy:

    class Player(object):
        def __init__(self, ... airplanes ...) # airplanes is a list of Airplane objects
            ...
            self.airplanes = airplanes
            ...
    
    class Airplane(object):
        def __init__(self, ... flights ...) # flights is a list of Flight objects
            ...
            self.flights = flights
            ...
    
    class Flight(object):
        def __init__(self, ... duration ...)
            ...
            self.duration = duration
            ...
    

    Then you can build and use the objects thus:

    player = Player(...[
        Airplane(... [
            Flight(...duration=10...),
            Flight(...duration=15...),
            ] ... ),
        Airplane(...[
            Flight(...duration=20...),
            Flight(...duration=11...),
            Flight(...duration=25...),
            ]...),
        ])
    
    player.airplanes[5].flights[6].duration = 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone I'm currently extremely frustrated and can not figure this out have looked
Hey everyone I have a script problem once again. I'm doing a jQuery show/hide
Hey everyone I am having a little problem with my jQuery I am trying
hey everyone, here is the site SEE BELOW I have a slight jquery problem
Hey everyone, I am having a problem with a website I'm trying to build;
Hey everyone I have a basic search function here that allows me to search
Hey everyone, running into a bit of an issue, I have created all my
Hey everyone, I have a database result that returns from a method. I need
Hey everyone. I have an exe file that runs a console program that was
Hey everyone. I'm really struggling to figure out the logic with this one and

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.