another naming convention topic: get prefix on none getter methods

Skip to first unread message

Rudi Hammad

May 11, 2021, 1:04:45 PMMay 11
to Python Programming for Autodesk Maya

So, I get the feeling that there isn't a clear naming convenction when it comes to use "get" as a prefix. I am not refering to the python @property, nor getter/setter methods. I am talking about normal methods.

My criteria is:
when ever I prefix a method with "get" it is because I am implying there is a "set". By doing that, just by this naming it hints the reader if it is a getter or normal method.
For instance, I do ~.pointsPositions() not  ~.getPointsPositions(). Reading that I am trying to hint the reader that there is no setPointsPositions().

Reading different apis, it seems there isn't a clear convention for this. Even within the same api you can find the prefix "get" almost randomly. Sometimes it might even be a getter that is not prefixed with get, but has its corresponding setter with the prefix "set".



Alok Gandhi

May 11, 2021, 2:02:42 PMMay 11
I have generously used prefix for methods 'get' without any 'set'.

I think there is no convention and my code readability is generally dictated by common sense and ease of understanding.

Another point is that functions/methods sgould always be verbs as long as possible. So pointPositions() to me does not feel like a natural function that 'does' something.

I would definitely use descriptor protocol (@property) wherever I can. It makes code beautiful, plus readonly attrs are easily managed by absence of a @setter.attr.

So overall, I would not stay away from get_ prefix in absence of a set_

You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Rudi Hammad

May 11, 2021, 2:46:54 PMMay 11
to Python Programming for Autodesk Maya

cool thanks for your opinion.
I do use @property in somesituations, not saying to stay away (in fact we had a discusion is another thread about it a while back)

I agree that function are usually verbes. And it is true that if you isolate the name pointPositions() it doesn't feel natural but being a method it would read as
myMesh.pointsPositions() which I think reads nice . For me myMesh.getPointsPositions() read well but in the back of my head I expecy myMesh.setPointPositions() too. Must be subjective I guess.

Rudi Hammad

May 11, 2021, 3:39:51 PMMay 11
to Python Programming for Autodesk Maya
For instance in the MFnCurve there are the methods degree(),  numCVs(), area(), lenght(), knot()... not getDegree(), getNumCVs(), getArea(), etc...
So I wonder if there is a logic for that. It looks like anything without 'get' prefix returns a number?? ...   ¯\_(ツ)_/¯
Reply all
Reply to author
0 new messages