altdesktop / i3ipc-python

🐍 An improved Python library to control i3wm and sway.
http://i3ipc-python.readthedocs.io
BSD 3-Clause "New" or "Revised" License
851 stars 109 forks source link

Regression: Reply-objects don't support indexing anymore #136

Closed s-ol closed 4 years ago

s-ol commented 4 years ago

This used to work:

print(i3ipc.Connection().get_workspaces()[0]['name'])

if I read this diff correctly, then both workspace.name and workspace['name'] used to work.

Should the ability to index via subscription be reimplemented? A simple addition like

class _BaseReply
    # ...
    def __getitem__(self, k):
        return getattr(self, k)

    def __setitem__(self, k, v):
        return setattr(self, k, v)

    def __delitem__(self, k):
        return delattr(self, k)

should suffice.

acrisci commented 4 years ago

Yeah this was a breaking change in 2.0. Why would you want both?

s-ol commented 4 years ago

For compatibility, it seems kind of unecessary to break this. This also isn't mentioned in the 2.0.1 release notes.

acrisci commented 4 years ago

You can put it back in like that if you want, but don't document it and mark it as deprecated.

s-ol commented 4 years ago

Okay... but if that means you will remove the feature again in a later update I will rather patch downstream.