Posts

Showing posts with the label typeerror

TypeError in python which says that dict object is not callable

TypeError in python which says that dict object is not callable I'm new to Python. I am getting the error TypeError:dict object is not callable . I haven't used dictionary anywhere in my code. TypeError:dict object is not callable def new_map(*arg1, **func): result = for x in arg1: result.append(func(x)) return result I tried calling this function as follows: new_map([-10], func=abs) new_map([-10], func=abs) But when I run it, I am getting the above error. 5 Answers 5 Seems like you are using arbitrary arguments when they are not required. You can simply define your function with arguments arg1 and func : arg1 func def new_map(arg1, func): result = for x in arg1: result.append(func(x)) return result res = new_map([-10], abs) print(res) [10] For detailed guidance on how to use * or ** operators with function arguments see the following posts: * ** ...

Why am I getting “TypeError: unorderable types: str() < int()” in this code?

Why am I getting “TypeError: unorderable types: str() < int()” in this code? @commands.command(pass_context=True) @checks.serverowner() async def change(self, ctx, change): channel = self.bot.get_channel('432738903221469186') change = ctx.message.clean_content[8:] now = datetime.now() count = len(self.changes.items()) + 1 self.changes[count] = {'date': now.strftime("%Y-%m-%d %H:%M:%S"), 'change': change} dataIO.save_json('data/local/changes.json', self.changes) await self.bot.send_message(channel, bold("N{SPARKLE} This change to the server was just made:") + box(change)) await self.bot.add_reaction(ctx.message, "N{WHITE HEAVY CHECK MARK}") Here is changes.json: { "1" : { "change" : "TEST", "date" : "2018-06-29 01:07:37" } } Here's the full error: 2|cdb_laun | Traceback (most recent call last): 2|cdb_laun | File ...