A few items that should get fixed on the Python side
-
A few issues I found in:
C:\Program Files\Maxon Cinema 4D 2023\resource\modules\python\libs\python39\c4d_init_.py
Line numbers are on the left36819: >>> # Matrix multiplication is not communicative, i.e., executing the transforms in a 36820: >>> # different order will yield another matrix product. 36821: >>> Z * Y * X 36822: >>> Matrix(v1: (0.5, -0.5, -0.707); v2: (0.146, 0.854, -0.5); v3: (0.854, 0.146, 0.5); off: (0, 0, 0))
36819: >>> # Matrix multiplication is not
communicativecommutative, i.e., executing the transforms in a
36820: >>> # different order
wil yield anothermay result in a completely differentmatrix product.
...
36822:
>>>Matrix(v1: (0.5, -0.5, -0.707); v2: (0.146, 0.854, -0.5); v3: (0.854, 0.146, 0.5); off: (0, 0, 0))
-------^ Remove erroneous >>> prefix from this line
Also, use of
id
for a parameter name in this code (and perhaps other places) is highly discouraged, because such use shadows the built-in functionid()
.
E.g.:>>> help(id) Help on built-in function id in module builtins: id(obj, /) Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (CPython uses the object's memory address.)
A simple suffix in front of
id
would be a good way to fix the issue and make the code more informative. E.g.:ob_id: int sub_cont_id: int # Etc.
I realize that
id
is used all over the code and this may not be a simple change, so just a suggested possibility for the next major set of refactoring changes.Finally the use of
l
as a variable name is highly discouraged (see: PEP 8: E741), because it can be easily mistaken for the digit1
, as you can clearly even see within the context of this forum's formatting of the two code excerpts forl
and1
! I see that the variable namev
is used for floating point values and the same name could be used for integral values, as well.For example, change:
37717: def SetInt32(self, id: int, l: int) -> None:
..., to:
37717: def SetInt32(self, id: int, v: int) -> None: # ---------------------------------^
-
Updated post with an additional item. I couldn't update the above post, because of the 3600 s timeout for editing.
C:\Program Files\Maxon Cinema 4D 2023\resource\modules\python\libs\python39\c4d_init_.py
Note: Code lines in the file are prefixed with their line numbers, for convenience.Instead of: (Note that the second
if
word in the statement on line 34544 is completely out of place)34543: | The index of the first and last selected elements in the given segment. 34544: | If the segment has a length of one, the same if will be set for the first and last entry in the tuple. 34545: | **None** if the function failed.
..., much clearer would be:
34543: | The index of the first and last selected elements
inofthe given segment.
34544: | For segments with a length of one, the indices of both elements will be set to the same value.
..., with line 34544 completely rewritten as shown in the above text (or something similar).If I find any more I will either update this message or post a new reply.
-
Hey @mikegold10,
thank you for reaching out to us and for taking the time to point these out; much appreciated. As a FYI, the line number and the
__file__
attribute a function/method/class carries are pretty much useless, as internally this data is stored in different files. Just name the class or function, you do not have to go through the effort of getting line numbers and file names, as I will not use them anyways.- Matrix.__mul__ and the Matrix Manual: I have fixed that, it will be published with an upcoming release.
BaseSelect.GetRange
: Hm, I would say this is very much a question of taste, both the preposition in and of are commonly used in such context as this sentence. But the preposition in denotes a location while of denotes ownership. Since the function returns the location of the first and last selected index, I would say in is a more fitting and the grammatically correct choice here. I therefore left this as is.
Regarding argument names shadowing built-in types and functions: We understand that this can be a bit annoying, but we strive for parity between C++ and Python and will therefore not change the names of arguments in Python. When you invoke functions/methods, this is not an issue as nothing will be shadowed. This is only a problem when you overwrite methods, and then you can rename them locally, as Cinema 4D will not call these methods with keywords, but always positionally.
import c4d class MyDialog (c4d.gui.GeDialog): def Command(self, id: int, msg: c4d.BaseContainer) -> bool: """The argument id shadows here the built-in function id(), not so nice. """ return super().Command(id, msg) def Command(self, cid: int, msg: c4d.BaseContainer) -> bool: """You can rename arguments as you please when overwriting methods. """ return super().Command(cid, msg)
For the same reason we will also not rename arguments for readability reasons. And there are also a lot of other PEP8 violations in the
c4d
andmaxon
modules due to our C++-first policy. This has been discussed multiple times internally, and we will not adopt PEP8 conformance for our APIs.Cheers,
Ferdinand -
@ferdinand said in A few items that should get fixed on the Python side:
Hey @mikegold10,
thank you for reaching out to us and for taking the time to point these out; much appreciated. As a FYI, the line number and the
__file__
attribute a function/method/class carries are pretty much useless, as internally this data is stored in different files. Just name the class or function, you do not have to go through the effort of getting line numbers and file names, as I will not use them anyways.- Matrix.__mul__ and the Matrix Manual: I have fixed that, it will be published with an upcoming release.
BaseSelect.GetRange
: Hm, I would say this is very much a question of taste, both the preposition in and of are commonly used in such context as this sentence. But the preposition in denotes a location while of denotes ownership. Since the function returns the location of the first and last selected index, I would say in is a more fitting and the grammatically correct choice here. I therefore left this as is.
Regarding argument names shadowing built-in types and functions: We understand that this can be a bit annoying, but we strive for parity between C++ and Python and will therefore not change the names of arguments in Python. When you invoke functions/methods, this is not an issue as nothing will be shadowed. This is only a problem when you overwrite methods, and then you can rename them locally, as Cinema 4D will not call these methods with keywords, but always positionally.
import c4d class MyDialog (c4d.gui.GeDialog): def Command(self, id: int, msg: c4d.BaseContainer) -> bool: """The argument id shadows here the built-in function id(), not so nice. """ return super().Command(id, msg) def Command(self, cid: int, msg: c4d.BaseContainer) -> bool: """You can rename arguments as you please when overwriting methods. """ return super().Command(cid, msg)
For the same reason we will also not rename arguments for readability reasons. And there are also a lot of other PEP8 violations in the
c4d
andmaxon
modules due to our C++-first policy. This has been discussed multiple times internally, and we will not adopt PEP8 conformance for our APIs.Cheers,
FerdinandI think you missed one of my corrections for
BaseSelect.GetRange()
to the second line of the Python comment that is neither grammatically correct nor informative:34544: | If the segment has a length of one, the same
->if<- ()will be set for the first and last entry in the tuple.
..., and my recommended correction that I feel is far more clear:
34544: | For segments with a length of one, the indices of both elements will be set to the same value.
With regard to the correction to the previous comment (i.e., the use of "in" vs "of" to start the subsequent preposition):
34543: | The index of the first and last selected elements
inofthe given segment.
..., the word "of" does not in any way indicate ownership, it is used simply to refer to the specific segment being discussed. For an issue such as this, where the wording is not strictly incorrect in terms of grammar, but the choice of words (IMHO) violates common English language usage patterns for expressing what is stated, I would very strongly urge you to run the two word possibilities by some native (American) English speakers at Maxon. It would be a very good idea to hear the opinions of others, before coming to a firm decision on this matter.
Believe me, I would not bother pursuing this point any further, if I did not feel that the present wording is very non-conventional, if not outright poor. I will go so far as to say that, in its present form, it sounds like either a non-native English speaker or a mechanical translator translating from a different language (e.g., German) came up with the present wording.
Michael
-
Hey @mikegold10,
first of all, I do truly appreciate you following up here with an answer. And yes, I am not a native speaker, and the person who wrote the respective text was probably neither.
34544: | If the segment has a length of one, the same ->if<- () will be set for the first and last entry in the tuple.
Hm, yeah, I did not read the second sentence, this sentence is obviously both syntactically and semantically meaningless. I think they meant here "When the segment has a length of exactly one, both elements of the tuple will index the same element." I will fix that, although I personally lean more towards removing the sentence altogether.
..., the word "of" does not in any way indicate ownership, [...]
It does, of is a possessive preposition, in is a relative preposition, specifically one that denotes a place. See here for an overview of the subject. I would not even challenge the fact that for you and your peers of might sound more natural (or maybe even all native speakers as you claim).
But language in general, and especially things like prepositions, pronouns, and flexions, is subject to language change which is often highly regional, so what people consider correct can vary regionally. As indicated in my first answer, prepositions are quite interchangeable, and if the text would have said of instead of in, I would not waste any time on changing that. But in the same notion, I cannot change the preposition on what you subjectively consider better. The grammatical situation from a Standard English point of view seems obvious here and personal preference cannot be grounds for a change. I am more than happy to change the preposition when you can demonstrate with a respectable English style guide like Oxford English that it would be more common to use here of. But that seems unlikely to me.
Cheers,
Ferdinand -
@ferdinand said in A few items that should get fixed on the Python side:
Hey @mikegold10,
..., the word "of" does not in any way indicate ownership, [...]
It does, of is a possessive preposition, in is a relative preposition, specifically one that denotes a place. See here for an overview of the subject. I would not even challenge the fact that for you and your peers of might sound more natural (or maybe even all native speakers as you claim).
But language in general, and especially things like prepositions, pronouns, and flexions, is subject to language change which is often highly regional, so what people consider correct can vary regionally. As indicated in my first answer, prepositions are quite interchangeable, and if the text would have said of instead of in, I would not waste any time on changing that. But in the same notion, I cannot change the preposition on what you subjectively consider better. The grammatical situation from a Standard English point of view seems obvious here and personal preference cannot be grounds for a change. I am more than happy to change the preposition when you can demonstrate with a respectable English style guide like Oxford English that it would be more common to use here of. But that seems unlikely to me.
Cheers,
FerdinandAs additional supportive evidence for my proposed change, I am providing a link to a respected source for the definitions of American English words, including many sample phrases that provide context for the often huge set of alternative definitions that are provided for commonly used words like "of" (and "in"):
Meriam-Webster Dictionary: of - Definition / preposition
Specifically, under the definitions of the word "of," when used as a preposition (i.e., Section 1 of 3 on the page, as linked above), please examine the following alternative definitions and examples of proper English usage that I believe are of relevance to my proposed change to the original Python comment:
-
- a, c, and e
-
- a and b
-
- b
-
Here is a copy of the original comment to provide context:
The index of the first and last selected elements in the given segment.
..., and the revised version that replaces the preposition in with of::
The index of the first and last selected elements of the given segment.
Of course the decision is yours to make. I am simply trying to "open your mind" to, as well as provide objective evidence for, an alternative phrasing which I perceive to be a better fit for the technical subject matter that is being documented, within the framework of modern American English usage patterns. I have to concede on the fact that this is ultimately subjective and may (or may not - not sure) be specific to the
en_US
locale.Michael
-