Repository navigation
Conversation
|
Nice demo! I think its not the reason Guido let match into the language -- it is just replacing if/else clauses. But that's a good place to start. Some things I noticed:
I guess we could always use a 3-tuple for the outer match -- rather than nested match statements. So we could reduce it to 2 indent levels... Fun -- Fun! :) |
rossbar
left a comment
There was a problem hiding this comment.
I think there's an opportunity to get rid of a layer of nesting here by including the method in the original match statement. AFAICT this would work for 3 of 4 cases -all those except the ones where only the target is specified, because there is special handling for the DiGraph case.
In practical terms I don't think doing so really buys anything other than a slight readability boost from one less level of indentation. Given that there's also warnings being raised for the all-pairs cases, my vote would be to hold off on making such a change until after that warning expires. All told, LGTM - thanks @MridulS !
|
Let's start this fresh. |
In the spirit of #7036 just wanted to test out how we can use structural matching in the context of networkx. I think
shortest_pathsis definitely a good candidate.I'm not sure if this is indeed the best way!
Once we have some basic agreement about this we can try to spread this across networkx :)
PS: I do like how the code reads!