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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:09:28+00:00 2026-05-30T07:09:28+00:00

I am turning some piece of Python code into OO-code. I define a class

  • 0

I am turning some piece of Python code into OO-code. I define a class and a two arguments constructor.

class myclass:
     MAX=5000
     FTOL = 10**(-10)
     TINY = 10**(-10)
     def __init__(self, initPt_,fun_):
         self.initPt = initPt_
         self.fun = fun_

With this code, I expect initPt and fun to be class members. I execute the code and write this instanciation in shell:

x=myclass([1,1],Optim.fun1)

where fun1 is a function defined in module Optim, that I accurately imported.

I added to myclass a function:

def build(self):
    self.initPt=self.initPt.append(self.fun(self.initPt))
    s=[self.initPt]
    for k in range(len(self.initPt)):
        temp=[x for x in self.initPt]
        temp[k]=self.initPt[k]+1
        s.append(temp)
    return s  

I call method build on the instance x I just created. This error appears:

for k in range(len(self.initPt)):
TypeError: object of type 'NoneType' has no len()

and indeed, if I add this test line in code:

print str(type(self.iniPt))

shell indicates that type is NoneType, althought I instanciated x with self.initPt = [1,1].

Moreover, if I write x.initPt in shell, result is accurate: [1,1,0.2] (after call of method build, third value is added to initial list [1,1]).

I don’t understand why it is not resolving type dynamically. It is not object programming then. What should I do?

Thanks and regards.

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

    This is at least part of your problem:

    self.initPt=self.initPt.append(self.fun(self.initPt))
    

    Using the append method of a list modifies the list in place and returns None. So this replaces the list assigned to self.initPt with None. Just do this:

    self.initPt.append(self.fun(self.initPt)) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some problems turning the SQL below into a Zend Db query.
I talked my team into turning on compiler warnings again. Some how all warnings
I'm turning a list into a set in Python, like so: request.session['vote_set'] = set(request.session['vote_set'])
Im pulling some data out of my webdb, turning it into html and wanting
If anyone knows how much of Visual Studio is turning into managed code? I
I have some jQuery code that highlights which radio button is checked by turning
So I need some way of turning given Protocol://URLorIP:Port string into string ip int
In some piece of our code we are using HibernateDaoSupport's setCacheQueries() method. At first
I'm losing some hair over Google's AJAX API currently. What I do is turning
So I'm attempting to use a queue to parse some input, turning prefix mathematical

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.