methods vs fields/members #48
Replies: 2 comments 2 replies
-
|
Yep those (chopChannels methods) could and probably should be set as read only properties. They can't be fields though since they are binding member methods not member values, so in the cases such as the chop_channels above it would need to be: .def_prop_ro("num_channels", &ChopChannels::channelCount)
.def_prop_ro("num_samples", &ChopChannels::valueCount)
.def_prop_ro("rate", &ChopChannels::rate)
.def_prop_ro("is_time_dependent", &ChopChannels::isTimeDependent)
.def_prop_ro("channel_names", &ChopChannels::channelNames, nb::rv_policy::reference_internal);For items like Properties in Python are typically used for values that:
Methods, are generally used when:
Based on the above both loaded() and frameDidFinish() fall into the method category ( All the chopChannels members such as Note you won't see many fields directly accessed in the main classes in TouchPy (Comp, ChopLink etc...), nearly all fields are private and are only access through there corresponding "get" functions (which don't use the word get. So the private fields: You can see in toplinkpy.cpp that there are a few structs such as |
Beta Was this translation helpful? Give feedback.
-
|
thanks for laying that out. I'll get on it! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey @keithlostracco,
see this discussion more in the gist of me trying to learn to navigate nanobind/touchpy internals.
While creating docstrings I see in several places Python methods defined, which don't have arguments and are read-only.
For instance in choplinkpy.cpp:
or these two methods in comppy.cpp
It seems these methods could all be read-only attributes (or 'members' in TouchDesigner docs terminology) which I believe is the same as read-only fields (in nanobind terminology).
So then would it be appropriate for me to change them like this?
Beta Was this translation helpful? Give feedback.
All reactions