File tree 1 file changed +8
-7
lines changed
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`?
237
237
238
238
It's not.
239
239
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
247
248
` instance.method() ` . This also works with built-in classes, for
248
249
example ` 'hello'.lower() ` is same as ` str.lower('hello') ` .
249
250
You can’t perform that action at this time.
0 commit comments