fixing stupid errors

This commit is contained in:
lda committed 2025-02-03 23:26:28 +07:00
1 parent 22f3d9c762
commit aaf329279a
2 files changed
+13 -9

No files matched your search

+9 -7
View File
@@ -685,14 +685,16 @@ def lda_set_example_arg(inst, arg):
" __init__ is a magic function that will run when you make a class instance"
LdaExampleClass = type(
"LdaExampleClass",
(object,),
"LdaExampleClass", # name of class
(object,), # inherit from who?
{
"__init__": lda_set_example_arg,
"lda_example_class_arg": 1,
"quadratic_builder": quadratic_builder,
"hello_world": hello_world,
"hello_to": hello_to,
"__init__": lda_set_example_arg, # calling LdaExampleClass().__init__() would call lda_set_example_arg
"lda_example_class_arg": 1, # a class property. it sticks to a class. not any instances.
"quadratic_builder": staticmethod(quadratic_builder),
"hello_world": staticmethod(hello_world),
"hello_to": staticmethod(
hello_to
), # so inst wont be passed in as first arg if i try lda1.hello_world() (the function dont take args)
},
)
+4 -2
View File
@@ -303,8 +303,10 @@
"\n",
"it can be a number, a string, a list (not advised), or a function?\n",
"\n",
"for a function in a class it would be marked a classmethod (`@classmethod`) and with classmethods the instance get passed in first arg.\n",
"`@staticmethod` used in the class block revert this behavior.\n",
"for a function in a class it would be marked a method and with methods the instance get passed in first arg. \n",
"so non of these implicit `this` that is always there like in java. first param of a method is always the instance.\n",
"\n",
"`@staticmethod` will revert this behavior. no more instance passed in as first param.\n",
"\n",
"check the tutorial.py file im lazy\n"
]