#Python people, I have a question about names. In the following example, what do you call the first line of this function (everything from `def` through the colon)?

Followup question: When someone refers to the "function definition" does that make you think of the entire function, or just part of it?

@ehmatthes I think of the first line as the signature or declaration. However, might be a useful data point for you to look at inspect.Signature (and friends) to stick with their terminology?

@ghickman @ehmatthes yeah, the first line is the signature, the definition is the whole thing, in the source (as contrasted with the object at runtime). Or something 🫠

@carlton @ghickman inspect.Signature has been really helpful for thinking through all this.

I wouldn't use "signature" for "the first line", because the signature is empty for a simple function with no parameters, and no return type.

@ghickman Does "header" seem reasonable? I wonder if "declaration" has meaning in other languages that doesn't align with that usage in Python.

Follow

@ehmatthes @carlton @ghickman As far as I know I have never heard "header" to describe any part of a function. I wouldn't know what you were referring to if you called it that.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.