File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change 1308
1308
" \n " ,
1309
1309
" - also called anti-pattern because there is only one instance of the class\n " ,
1310
1310
" - use `__new__()` method to create a new instance of the class\n " ,
1311
+ " _ `__new__()` is a class method that is called before the `__init__()` instance method\n " ,
1311
1312
" - use `cls` parameter to check if the instance is already created\n " ,
1312
1313
" - return the instance if it's already created\n " ,
1313
- " - otherwise, create a new instance and return it"
1314
+ " - otherwise, create a new instance and return it\n " ,
1315
+ " - `__new__()` method takes the `cls` as the first argument\n " ,
1316
+ " - also takes the rest of the arguments that are passed to the `__init__` method"
1314
1317
]
1315
1318
},
1316
1319
{
You can’t perform that action at this time.
0 commit comments