File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -237,13 +237,14 @@ But is `stackoverflow.info` the same thing as `Website.info`?
237237
238238It's not.
239239
240- Instead, ` stackoverflow.info ` is a ** method** . Functions as class
241- attributes can be accessed as methods from instances. Effbot also
242- has a ` .info ` method. So ` Website.info(stackoverflow) ` does the same
243- thing as ` stackoverflow.info() ` , and when ` stackoverflow.info() ` is
244- called it automatically gets ` stackoverflow ` as an argument.
245-
246- In other words, ` Class.method(instance) ` does the same thing as
240+ Instead, ` stackoverflow.info ` is a ** method** . If we set a function as a
241+ class attribute, the instances will have a method with the same name.
242+ Methods are "links" to the class attribute functions. So
243+ ` Website.info(stackoverflow) ` does the same thing as ` stackoverflow.info() ` ,
244+ and when ` stackoverflow.info() ` is called it automatically gets
245+ ` stackoverflow ` as an argument.
246+
247+ In other words, ` Class.method(instance) ` does the same thing as
247248` instance.method() ` . This also works with built-in classes, for
248249example ` 'hello'.lower() ` is same as ` str.lower('hello') ` .
249250
You can’t perform that action at this time.
0 commit comments