@djangoproject · Post #155 · 09/04/2016, 12:23 PM
https://anthony-zhang.me/blog/python-bound-methods/ when & why we use @#staticmethod
Hashtags
TGINSIGHT SIMILAR POSTS
Source channel @olddriverGDstudy · Post #10 · Mar 17
#语录 请大家做个素质狼友: 1 人和人需要的是相互尊重的,希望我们群的狼友能尊重老师。在相互尊重的情况下我相信大家会得到更好的体验。 2 请大家预约老师后如有变化应该尽快,提前的告知老师,因为老师每天的课时都是有限的。如果不提前告知也很可能再也约不到这位老师或者进入妹子们的黑名单。 3 请大家遵守行规(按照行规S了但是可以待够时间,享受下老师的服务和老师聊聊天。就算时间到了没S也算是课时结束了,如果第一次结束了又做第二次那么不管S没有都应该按PP付费。),一般情况下P是60分钟 PP是90分钟 时间没到老师赶你走是老师的问题,但是超时就是狼友的问题,关于超时最好和老师协商一下,因为老师如果后面有学生,那么超时就会影响到后面的学生,很可能会给老师带来不必要的麻烦。如果想约PP的学生最好在预约的时候就给老师讲清楚。 4 关于等候的时间,有些时候有很多不可控因素比如学生迟到,学生学习时间长等因素,希望大家在等候的时候能稍微耐心点,个人感觉等候时间在20-30分钟还是可接受的。 5 希望我们群的兄弟都能做个素质狼友,当然我们也会对群里的各位老师有所要求,大家对老师有什么不满意的都可以在群里直接投诉,或者找管理员投诉。
Hashtags
Search: #staticmethod
@djangoproject · Post #155 · 09/04/2016, 12:23 PM
https://anthony-zhang.me/blog/python-bound-methods/ when & why we use @#staticmethod
Hashtags
@djangoproject · Post #593 · 04/13/2018, 07:48 PM
@#classmethod vs @#staticmethod vs "plain" methods What's the difference? class MyClass: def method(self): """ Instance methods need a class instance and can access the instance through self. """ return 'instance method called', self @classmethod def classmethod(cls): """ Class methods don't need a class instance. They can't access the instance (self) but they have access to the class itself via cls. """ return 'class method called', cls @staticmethod def staticmethod(): """ Static methods don't have access to cls or self. They work like regular functions but belong to the class's namespace. """ return 'static method called' # All methods types can be # called on a class instance: »> obj = MyClass() »> obj.method() ('instance method called', <MyClass instance at 0x1019381b8>) »> obj.classmethod() ('class method called', <class MyClass at 0x101a2f4c8>) »> obj.staticmethod() 'static method called' # Calling instance methods fails # if we only have the class object: »> MyClass.classmethod() ('class method called', <class MyClass at 0x101a2f4c8>) »> MyClass.staticmethod() 'static method called' »> MyClass.method() TypeError: "unbound method method() must be called with MyClass " "instance as first argument (got nothing instead)"
Hashtags
@djangoproject · Post #385 · 07/15/2017, 04:17 PM
# @classmethod vs @staticmethod vs "plain" methods # What's the difference? class MyClass: def method(self): """ Instance methods need a class instance and can access the instance through self. """ return 'instance method called', self @classmethod def classmethod(cls): """ Class methods don't need a class instance. They can't access the instance (self) but they have access to the class itself via cls. """ return 'class method called', cls @staticmethod def staticmethod(): """ Static methods don't have access to cls or self. They work like regular functions but belong to the class's namespace. """ return 'static method called' # All methods types can be # called on a class instance: »> obj = MyClass() »> obj.method() ('instance method called', <MyClass instance at 0x1019381b8>) »> obj.classmethod() ('class method called', <class MyClass at 0x101a2f4c8>) »> obj.staticmethod() 'static method called' # Calling instance methods fails # if we only have the class object: »> MyClass.classmethod() ('class method called', <class MyClass at 0x101a2f4c8>) »> MyClass.staticmethod() 'static method called' »> MyClass.method() TypeError: "unbound method method() must be called with MyClass " "instance as first argument (got nothing instead)" #classmethod#staticmethod
Hashtags
@djangoproject · Post #126 · 08/31/2016, 02:13 AM
goo.gl/QkvD2L #staticmethod #Classmethod
Hashtags
@djangoproject · Post #87 · 07/11/2016, 11:53 AM
https://docs.python.org/3/library/functions.html#staticmethod #staticmethod(function) Return a #static method for function. A static method does not receive an implicit first argument. To declare a static method, use this idiom: class C: @staticmethod def f(arg1, arg2, ...): ... The @staticmethod form is a function decorator – see the description of function definitions in Function definitions for details. It can be called either on the class (such as C.f()) or on an instance (such as C().f()). The instance is ignored except for its class. Static methods in Python are similar to those found in Java or C++. Also see classmethod() for a variant that is useful for creating alternate class constructors. For more information on static methods, consult the documentation on the standard type hierarchy in The standard type hierarchy. class str(object='') class str(object=b'', encoding='utf-8', errors='strict') Return a str version of object. See str() for details. str is the built-in string class. For general information about strings, see Text Sequence Type — str.
Hashtags