TGTGInsighttelegram intelligenceLIVE / telegram public index
← Find Blog👁发现博客

TGINSIGHT SIMILAR POSTS

查找相似内容

Source channel @FindBlog · Post #343 · 11月29日

写了三年博客,多多少少对写博客、建博客有一点了解,之前在 V2EX 看到这样一条帖子:想给一个女性作家朋友搭建一个博客网站,有什么成熟点的方案 网友评论了很多,有价值的也不少,我在此摘录几条我认为有用的: 1️⃣作家应该不是程序员吧? 不明白为何那么多人还无脑推要用 git 的静态博客…… wordpress 吧,要是觉得卡顿,安利一下 zblogphp,很好用,主题也不少。 2️⃣Wordpress 插件多 技术成熟。。别信楼什么什么 github+hexo 的 别人又不是程序员,markdown 也做不了复杂的页面布局 3️⃣虚拟空间 + Typecho / Wordpress 或者博客平台.不要净搞些幺蛾子,还不好使(你朋友表示) 你以为很秀的操作在外行人眼中看来即不实际也不好使. 4️⃣大家还是偏极客了吧,程序员之外,愿意写 markdown,自己 git 提交的用户多吗? 还是有一个易用的后台,广泛的插件、主题选择,也真没有比 wordpress 更好的了。 5️⃣推静态博客的不是蠢就是坏,又不是人人都是程序员。 也不建议自己搭,因为没人做 SEO,没啥用。 建议直接买成熟的平台,或者就地取材。 #博客

Hashtags

Results

找到 5 条相似帖子

搜索 #staticmethod

当前筛选 #staticmethod清除筛选
djangoproject

@djangoproject · Post #593 · 2018/04/13 19:48

@#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 · 2017/07/15 16:17

# @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 · 2016/07/11 11:53

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.