you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 11 months ago (2 children)

It never occurred to me that you could assign fields to a function. I mean, it totally makes sense considering that functions are objects in Python. It just never occurred to me that this is a thing one can do. Crazy.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 11 months ago (1 child)

    Please don't do that, I was stupid when I wrote that. But still, in very dynamic languages like python or js everything is an object, including functions, so you can just do object stuff on them.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 11 months ago

    I wasn't going to, and after I saw it it totally makes sense that it's possible, it just never occurred to me.

    I guess this could be used like static variables inside functions in c. So scope-limited global variables. Not a good design choice in most cases.

  • source
  • parent