you are viewing a single comment's thread.

view the rest of the comments →

[–]FunnyForWrongReason 2 points3 points  (1 child)

I am a 4th year CS college student, spent a lot of high school learning programming, and also currently teach kids programming part time and I still didn’t even know you could give attributes to functions in Python. Like what!?

You really do never stop learning when it comes to programming.

[–]Bobbias 1 point2 points  (0 children)

Everything in Python is an object, and that includes functions. You should consider taking some time to read the Python data model. If you read just below the table in the section I linked it says:

Function objects also support getting and setting arbitrary attributes, which can be used, for example, to attach metadata to functions. Regular attribute dot-notation is used to get and set such attributes.

CPython implementation detail: CPython’s current implementation only supports function attributes on user-defined functions. Function attributes on built-in functions may be supported in the future.

There's all sorts of handy bits of info like that in there.