The python built-in dir returns a RunTimeError on a grb message. This is an essential function for understanding how to interact with an object. Can we make this work? I'm glad to submit a PR, with some guidance. It looks like this is the class that needs to be adjusted:
(Pdb) dir(grb)
[.... list of all methods and properties for the class including but not limited to data, latlons, tostring, keys, etc, etc... ]
From the docs on dir (linked above):
If the object has a method named dir(), this method will be called and must return the list of attributes. This allows objects that implement a custom getattr() or getattribute() function to customize the way dir() reports their attributes.
If the object does not provide dir(), the function tries its best to gather information from the object’s dict attribute, if defined, and from its type object. The resulting list is not necessarily complete and may be inaccurate when the object has a custom getattr().
I believe this paragraph's may contain the solution and the problem. There is no __dir__() method on gribmessage class. So it is trying to gather the info from __dict__ and somehow I guess it is that, which raises the RunTimeError. But alas, I don't know cython well, and that could make it more complicated.
The python built-in dir returns a
RunTimeError
on agrb
message. This is an essential function for understanding how to interact with an object. Can we make this work? I'm glad to submit a PR, with some guidance. It looks like this is the class that needs to be adjusted:https://github.com/jswhit/pygrib/blob/master/src/pygrib/_pygrib.pyx#L721
Setup:
Example calls:
Desired result:
From the docs on
dir
(linked above):I believe this paragraph's may contain the solution and the problem. There is no
__dir__()
method on gribmessage class. So it is trying to gather the info from__dict__
and somehow I guess it is that, which raises theRunTimeError
. But alas, I don't know cython well, and that could make it more complicated.