Python Forum
TypeError: 'NoneType' object is not callable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: 'NoneType' object is not callable
#3
Quote: I searched the net and read some pages but I did not understand how to correct the code.

I googled "TypeError: 'NoneType' object is not callable" and this was the very first hit.

https://www.geeksveda.com/typeerror-none...-callable/
“TypeError: 'nonetype' object is not callable” occurs when you try to call a None value as if it were a function. To solve it, make sure that you do not override the names of any functions with a None value.

This is exactly what you did here.
def memorize(func):
    cash={}
    def wrapper(*args):
        if args in cash:
            return cash[args]
        else:
            result=func(*args)
            cash[atgs]=result
            return result
        return wrapper  # <-- Indentation error
Because of the indentation error, calling memorize(sum_of_odd_numbers) returns None when you wanted it to return sum_ov_numbers.wrapper. This means when you called sum_of_odd_numbers(10) you ended up calling None(10).
akbarza likes this post
Reply


Messages In This Thread
RE: TypeError: 'NoneType' object is not callable - by deanhystad - Aug-23-2023, 02:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 520 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 606 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 825 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,520 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Need help with 'str' object is not callable error. Fare 4 908 Jul-23-2023, 02:25 PM
Last Post: Fare
  Python: Regex is not good for re.search (AttributeError: 'NoneType' object has no att Melcu54 9 1,654 Jun-28-2023, 11:13 AM
Last Post: Melcu54
  TypeError: 'float' object is not callable #1 isdito2001 1 1,130 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  TypeError: a bytes-like object is required ZeroX 13 4,504 Jan-07-2023, 07:02 PM
Last Post: deanhystad
  'SSHClient' object is not callable 3lnyn0 1 1,231 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,565 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020