TGTGInsighttelegram intelligenceLIVE / telegram public index
← GZ学习频道

TGINSIGHT SIMILAR POSTS

Find similar content

Source channel @olddriverGDstudy · Post #51 · Mar 24

#上头诫#知识 噫吁嚱,呜呼哀哉。佳丽之心, 如渊似海云雾间。前有鬼者心有属,今有上将四人间。心似骄阳深似火,怎当白桓是真心。柳间戏水不得喻,错将弱颜当磐石。今日不见凄鬼之心散步言语现,此时却如千万金石尽如吼头甜。千言万语悬浮脑海间,百转千回纠缠心火炼。上将游戏四水间,怎奈四水通流涧。不得可可不得乖,碧水深潭心坏怜。心知真己不觉少,奈何四水风见消。索向索梁不觉走,回神已在深涧见。深涧云气鬼雾袅,崖山悬顶有佳囡。云烟做红霞,鬼雾做红妆。似是云波似是锦,可文鬼泣是有心。东升日出朝阳起,云散无效鬼泪去。不知南柯曾觉晓,梦里梦外梦惺惺。囡囡心念念,鬼鬼向戚戚。柳七窃窃似潇潇,新年却已入人牢。谁知何时却明晓,涉水不足总深腰。无问无知无所念,有情有景有春宵。尽知尽晓秀哥谣,不管不顾十诫飘。愿此流真做悲景,莫要上头惹人笑。

Results

5 similar posts found

Search: #staticmethod

当前筛选 #staticmethod清除筛选
djangoproject

@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)"

djangoproject

@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

djangoproject

@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.