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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:02:29+00:00 2026-05-31T14:02:29+00:00

I am a Python noob. To learn I’m making a natural selection simulator but

  • 0

I am a Python noob. To learn I’m making a natural selection simulator but I’m a bit stuck.

A bit of background:

I make a list of organisms with random bit patterns, like so:

population.append(chromosone.Chromosone(chromosoneSize))

Organisms breed, so I have a @classmethod to allow an organism to be created based on a combination of it’s parents bit patterns, like so:

population.append(chromosone.Chromosone.makeChromo(newOrganism)) 

At some points I return the gene from an organism, like so:

def returngene(self):
“””Return the gene”””
return self.gene

This works for organisms created by chromosone.Chromosone(chromosoneSize) but not for organisms created with chromosone.Chromosone.makeChromo(newOrganism). I get this error:

AttributeError: 'NoneType' object has no attribute 'returngene'

UPDATE: I have given my makeChromo() a return, like so:

@classmethod
def makeChromo(cls, bits):
    obj = cls
    obj.gene = bits
    return obj

But I now get this error:

TypeError: unbound method returngene() must be called with Chromosone instance as first argument (got nothing instead)

returngene() is a simple method that returns the gene (a string).

I think my misunderstanding lies in the @classmethod and how Python works with types and objects?

  • 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-31T14:02:30+00:00Added an answer on May 31, 2026 at 2:02 pm

    AttributeError: ‘NoneType’ object has no attribute ‘returngene’

    This error happens when you try to access an attribute on the special None object. In your case you are trying to read the method returngene in order to call it. Clearly population[each] evaluates to None.

    Your next step is to work out why population[each] evaluates to None. Presumably one of the items that you appended to population was None. And following that through we conclude that one of

    chromosone.Chromosone(chromosoneSize)
    

    or

    chromosone.Chromosone.makeChromo(newOrganism)
    

    returns None.

    Now you know why this error occurs, you should be able to track down the root cause.

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

Sidebar

Related Questions

Apologies for the noob Python question but I've been stuck on this for far
Python noob trying to learn Pylons. I'm using the QuickWiki tutorial ( http://pylonshq.com/docs/en/1.0/tutorials/quickwiki_tutorial/ )
Python noob using 2.7 on Windows. I'm working on making a hierarchy tree view
I'm somewhat of a noob to python but I'm trying to create a recursive
Using python to pick it some pieces so definitely a noob ? here but
this may sound like a strange question from a Python noob, but here's the
Complete noob here wanting to learn Python. I installed Python, then Eclipse, then PyDev.
Python noob... please be gentle. In my current program, I have a list of
Ok.. I am a noob to Python but work with PHP a lot. Basically
I am a Python noob. I create a class as follows: class t1: x

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.