-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add index getter/setter into attributes dict for Common base class #223
base: master
Are you sure you want to change the base?
Conversation
Hi @ansonmiu0214, thanks for this suggestion and sorry for not replying earlier. This is also just a quick reply, I have not had time to look at your proposal in detail. I was wondering if we could not better use Python I will look at it in more detail during development of pydot 2.0.0. |
Ok, I guess the main benefit of your proposal is the indexing: |
This pull request has conflicts, please resolve those so that the changes can be evaluated. |
A very old PR, I know, but regardless... IMHO this is not a bad idea; the ability to treat an object as a dict comes in extremely handy at times. There's a lot that can be done programmatically with dict-style access, as @ansonmiu0214 demonstrated. And these methods don't conflict with any other access methods, so there's no real harm. But the generated Not-so-smooth operatorHowever, as-is (modulo it being updated to address conflicts due to file renames and etc.), this will cause issues because of the way Python implements some of its standard operators. (Strangely enough, this just came up in a completely different context recently, so it's fresh in my mind.) In particular, providing only the The
So, by providing At least a Useful, but not imperativeGranted @ansonmiu0214's example above could also be rewritten as... label, payload = ([edge.get(attr) for attr in attrs]) So it's not like this is necessary. But it's still nice to have, at times. Providing a edge.update({
"label": "This is my edge",
"style": "dashed",
"color": "red",
}) That seems like even more of a clear win, as it can't easily be replaced with other methods of access. |
This allows for getting and setting Edge attributes with attribute names stored in variables, i.e.