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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:40:47+00:00 2026-05-24T07:40:47+00:00

Imagine the following class that displays some sort of hierarchy: class BaseList2D(object): def __init__(self):

  • 0

Imagine the following class that displays some sort of hierarchy:

class BaseList2D(object):
    def __init__(self):
        self._superobject   = None
        self._subobjects    = []

    def InsertUnder(self, other):
        if self not in other._subobjects:
            other._subobjects.append(self)
            self._superobject   = other
            return True
        return False

    def InsertAfter(self, other):
        parent  = other._superobject
        if not parent:
            return False

        parent  = parent._subobjects
        parent.insert(parent.index(other) + 1, self)
        return True

    def GetDown(self):
        if not len(self._subobjects):
            return
        return self._subobjects[0]

    def GetNext(self):
        if not self._superobject:
            return
        stree   = self._superobject._subobjects
        index   = stree.index(self)
        if index + 1 >= len(stree):
            return
        return stree[index + 1]

Is it really the best (or the only) way to set the superobject of other by accessing it’s hidden attribute ? The attribute should not be set by the user ..

  • 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-24T07:40:48+00:00Added an answer on May 24, 2026 at 7:40 am

    _foo is just a naming convention. Usually, there would be a property or something that sets the ‘private’ variable for you. If not, the convention is being (slightly) misused.

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

Sidebar

Related Questions

Consider the following example: class A: @property def x(self): return 5 So, of course
Imagine the following: class Repository { private ObservableCollection<ModelClass> _allEntries; public ObservableCollection<ModelClass> AllEntries { get
Imagine the following template class (setter and getter for the member _t omitted): template<class
Imagine I have a class that represents a simple washing machine. It can perform
Just imagine you have the following class [DataContract] public class NamedList { [DataMember] public
Imagine the following classes: class A { public string Test {get; set;} } class
Imagine the following situation: class IAlarm : public boost::enable_shared_from_this<IAlarm> { boost::shared_ptr<IAlarm> getThisPointerForIAlarm() { return
Imagine that I have a Debtor class. With Hibernate, I will define the class
Imagine the following two classes of a chess game: TChessBoard = class private FBoard
I have two classes: class Activity < ActiveRecord::Base belongs_to :activity_type def belongs_to_cat_a? self.activity_category ==

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.