TGTGInsightтелеграм анализLIVE / telegram public index
← Такты, стеки, два колеса

TGINSIGHT SIMILAR POSTS

Намери подобно съдържание

Изходен канал @clockstackwheels · Post #1087 · 18.04

Мне очень нравится монолог детектива из фильма «Достать ножи: Стеклянная луковица». По сюжету эксцентричный миллиардер, «непонятый гений» Майлс Брон собирает своих друзей на личном острове на вечеринку, и закручивается дело. Детектив Бенуа Бланк, оказавшийся там же, проводит с этими мажорами несколько дней, и ближе к концу рассказывает им, как его осенило, и он нашёл ключ к делу. Классический детективный сюжет, но сам монолог очень проникновенный, потому что Бланк эмоционально сокрушается, рассказывая о том, как у него в голове что-то не сходилось, как нечто постоянно не давало ему покоя. Приводит в пример различные мелочи: миллиардер выдумывал несуществующие слова, неверно применял другие слова, ошибался в фактах, не самостоятельно делал всякие крутые вещи, которыми хвастается, а то, что сделал или придумал он сам, оказалось неработоспособно. И он приходит к такому выводу: Майлс Брон на самом деле идиот. Он глупый. Заработанные им деньги и миллиардная корпорация объясняются как-то ещё (в итоге сюжет даёт ответы на это), а чел просто тупой. И с помощью принятия этой гипотезы куча деталей встали на свои места. Вот и в жизни можно применять. Если ты слишком долго не можешь объяснить поведение какого-то человека, попробуй предположить, что он тупой. Почти Бритва Хэнлона, но более персонализированная. Бывший игрок в интеллектуальную игру несёт отборнейшую неадекватную ересь? Возможно, он просто тупой, а навык игры это единственное, что он в себе развивал. Автор хороших текстов становится наглухо отбитым пропагандистом сомнительной политической позиции? Возможно, он просто тупой, а способность сочинять тексты не даёт умение адекватно видеть вещи вокруг. Опытный специалист в какой-то сфере отрицает профессиональные подходы? Возможно, он просто тупой, а годы работы не сказались значимо на росте навыков. Знаменитый владелец крупного сервиса придумывает неправдоподобные кринжовые оправдания своих косяков? Возможно,... хотя не, в этом случае обычно идёт игра на публику и вера в то, что тупые как раз зрители. Но тоже так себе. И всё равно, в большом подмножестве случаев метод, кажется, работает.#life

Hashtags

Резултати

Намерени 5 подобни публикации

Търсене: #staticmethod

当前筛选 #staticmethod清除筛选
djangoproject

@djangoproject · Post #593 · 13.04.2018 г., 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 · 15.07.2017 г., 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 · 11.07.2016 г., 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.