Skip to content
Advertisement

Python: Why do I get an “unexpected keyword argument” error? [closed]

I am trying to set up a graph. For the initialization, I wanted the option of either starting with a collection of nodes and edges or not. So I gave them the default value None. Or so I thought:

JavaScript

(the msg part was for testing the code with the simplest example possible)

What I got was:

JavaScript

Can anybody help me? It’s probably a ridiculously simply thing, but I just don’t see it, and I’m going slightly mad here…

Advertisement

Answer

You’ve defined Graph not as a class but as a regular function.

Replace def Graph(): with class Graph:.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement