Python's in
Do you have a good reference on Python's class in-built function? To me, this function needs a bit of picking up. It looks extremely powerful, but I haven't quite got my head around it and am looking for a good guide.
i am speaking about this:
class squash():
def __init___(self, chocolate)
i just don't understand them
In Python class
is not a built-in function, it is a compound statement used for creating classes. This is described in the docs in the following locations:
https://docs.python.org/2/reference/compound_stmts.html#class-definitions https://docs.python.org/2/tutorial/classes.html
If you are looking for a function to dynamically create a class, you would want the three argument version of the built-in function type()
.
As for a tutorial on how to use classes in Python, the following is pretty good:
http://learnpythonthehardway.org/book/ex40.html
They are often referred to as magic methods. Here is a good resource: http://www.rafekettler.com/magicmethods.pdf
链接地址: http://www.djcxy.com/p/4538.html上一篇: 为什么我需要做`
下一篇: Python的英寸