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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:31:51+00:00 2026-06-10T00:31:51+00:00

I’m sort of newish to Python, I’ve hit a really weird problem with my

  • 0

I’m sort of newish to Python, I’ve hit a really weird problem with my dictionary that I just can’t seem to figure out.

Basically I have a class called World which has a dictionary self.islands = {} the problem is when I want to add an instance of my Island class using the method addIsland(island) in World I get the error:

AttributeError: World instance has no attribute ‘islands’

on the line:

self.islands[island.name] = island

self.islands definitely exists because I initialize it in World‘s __init__ as follows:

class World():
    def __init__(showBase, self):        
        self.islands = {}
        ...

The addIsland method is:

def addIsland(self, island):
    island.setWorld(self)
    self.islands[island.name] = island

And that method is called from the base class’s __init__ (which main runs) as follows:

self.world = World(self)
self.setupIslands()

self.setupIslands() looks like:

def setupIslands(self):
    #Island 1
    island1 = IslandCross()
    self.world.addIsland(island1)

Sorry if it is a bit confusing but basically I’ve got 3 classes, the base one that has a main, in it’s __init__ it calls self.world = World(self) then self.setupIslands().

World’s __init__ has the line self.islands = {} and the method addIsland() which tries to add an Island to the dictionary with the key as the island’s name (island.name) and it’s value as the island instance itself.

What am I doing wrong here? I’m pretty sure I’ve got this kind of setup working in other places in my projects.

I bet it’s something stupid and simple isn’t it 🙂

Thanks for your time,

InfinitiFizz

  • 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-06-10T00:31:52+00:00Added an answer on June 10, 2026 at 12:31 am

    The self-reference is the first argument to methods.

    def __init__(self, showBase):
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into

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.