Skip to content

Latest commit

 

History

History
42 lines (26 loc) · 850 Bytes

l3.rst

File metadata and controls

42 lines (26 loc) · 850 Bytes

Python's Attributes

Reminder

a message send consists of two steps:

  • lookup the message implementation
  • activate (i.e. call) the method that was found in this way

those are done in one step, not visible to the programmer

Attributes

in Python, those steps are separated in the language:

obj.method(argument_1, ..., argument_n)

is identical to:

m = obj.method
m(argument_1, ..., argument_n)

Bound methods

  • The object m is called a bound method
  • it can be called like a function
  • it is bound to the object out of which it was read
  • the bound method thus takes one less argument than the original method
  • thus reading methods out of objects behave like object-attributes