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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:40:41+00:00 2026-05-27T03:40:41+00:00

I am new to Python and working with a set of objects (Node) and

  • 0

I am new to Python and working with a set of objects (Node) and just trying to iterate over the set of objects and printout the variable ‘H’. Unfortunately I keep getting the error: (“AttributeError: ‘NoneType’ object has no attribute ‘H'”). Any insight as to why this is happening would be greatly appreciated.

Here is my class Node that is stored in the set.

class Node:
    def __init__(self, row, col, heuristic):
        self.row = row
        self.col = col
        self.H = heuristic
        self.parent = None

    @classmethod
    def with_parent(self, row, col, heuristic, parent):
        self.row = row
        self.col = col
        self.H = heuristic
        self.parent = parent

Here is the set with the first Node being entered. Later on more nodes are entered but for now just adding one is still creating a headache

open_list = set()
start_row, start_col = start_loc
open_list.add(Node(start_row, start_col, 0))

And here is the line of code throwing the error: (“AttributeError: ‘NoneType’ object has no attribute ‘H'”)

for open_node in open_list:
    sys.stdout.write("H: " + str(open_node.H))

Once I can get this worked out the real goal is to sort on the Heuristic.

current = sorted(open_list, key=lambda open: open.H)[0]
  • 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-27T03:40:41+00:00Added an answer on May 27, 2026 at 3:40 am

    The error “AttributeError: ‘NoneType’ object has no attribute ‘H'” means that one of the Nodes in open_list is being assigned the value ‘None’ instead of being initialized. Does anything happen to open_list between the lines you show and the line with an error?

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

Sidebar

Related Questions

I am pretty new to python and working with firmata I am trying to
I am new to Python, and I'm working on writing some database code using
Im new two python and am trying to grow a dictionary of dictionaries. I
I am the new maintainer for an in-house Python system that uses a set
i'm not particularly new at python but i just thought there might be a
I'm new to Python from the R world, and I'm working on big text
I'm working on a MUD (Multi User Dungeon) in Python and am just now
I am new to Python. I am working on gps files. I need to
I am new to python, mongodb and sql. I am working in Eclipse 3.7.1
I have just started working at a new place and they don't have any

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.