masto.es es uno de los varios servidores independientes de Mastodon que puedes usar para participar en el fediverso.
Bienvenidos a masto.es, el mayor servidor de Mastodon para hispanohablantes de temática general.

Administrado por:

Estadísticas del servidor:

1,9 K
usuarios activos

#decorator

0 publicaciones0 participantes0 publicaciones hoy
Gay Curmudgeon<p>Redecorating the bathroom with a shower curtain sewed by my mother 45 years ago. <a href="https://mastodon.social/tags/homedecor" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>homedecor</span></a> <a href="https://mastodon.social/tags/interiordecorating" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>interiordecorating</span></a> <a href="https://mastodon.social/tags/interiordecoration" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>interiordecoration</span></a> <a href="https://mastodon.social/tags/interiordecorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>interiordecorator</span></a> <a href="https://mastodon.social/tags/decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>decorator</span></a> <a href="https://mastodon.social/tags/interiors" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>interiors</span></a> <a href="https://mastodon.social/tags/home" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>home</span></a> <a href="https://mastodon.social/tags/homeandgarden" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>homeandgarden</span></a> <a href="https://mastodon.social/tags/decor" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>decor</span></a> <a href="https://mastodon.social/tags/bath" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>bath</span></a> <a href="https://mastodon.social/tags/bathrooms" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>bathrooms</span></a> <a href="https://mastodon.social/tags/showercurtain" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>showercurtain</span></a> <a href="https://mastodon.social/tags/jungleprint" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>jungleprint</span></a> <a href="https://mastodon.social/tags/jungle" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>jungle</span></a></p>
STREET ART UTOPIA<p><strong>Revenge on the Wall: Painter’s Message Goes Viral in Bolsover</strong></p> <p>In January 2020, a quiet street in Bolsover, England, became the unlikely setting for a bold act of revenge that quickly made headlines across the UK. </p> <p>When a dispute between a painter and his client reached boiling point, the result was a striking message that turned the town into the center of national attention.</p> <p>The Dispute That Sparked It All </p> <p>Dean Reeves, a professional painter and decorator, was hired to transform the exterior of the former North Star Club building, which was being […]</p> <p><a href="https://streetartutopia.com/2025/06/18/revenge-on-the-wall-painters-message-goes-viral-in-bolsover/" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">streetartutopia.com/2025/06/18</span><span class="invisible">/revenge-on-the-wall-painters-message-goes-viral-in-bolsover/</span></a></p>
michabbb<p><a href="https://social.vivaldi.net/tags/PHP" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>PHP</span></a> <a href="https://social.vivaldi.net/tags/Laravel" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Laravel</span></a> <a href="https://social.vivaldi.net/tags/Design" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Design</span></a> Pattern: Improving <a href="https://social.vivaldi.net/tags/Telescope" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Telescope</span></a> with Unorthodox <a href="https://social.vivaldi.net/tags/Decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Decorator</span></a> 🧩</p><p>When standard debugging tools couldn't handle a complex <a href="https://social.vivaldi.net/tags/API" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>API</span></a> (JSON wrapped in Base64 wrapped in <a href="https://social.vivaldi.net/tags/SOAP" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>SOAP</span></a>), a creative solution emerged.</p><p>🧵 👇</p>
ƧƿѦςɛ♏ѦਹѤʞ<p><a href="https://mastodon.social/tags/Painter" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Painter</span></a> and <a href="https://mastodon.social/tags/Decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Decorator</span></a></p>
Olivier Mehani<p><strong>I don’t often decorate classes, but when I did, I didn’t have to</strong></p><p>I have played with <a href="https://blog.narf.ssji.net/2022/11/22/fun-with-python-decorators/" rel="nofollow noopener" target="_blank">Python</a> <a href="https://blog.narf.ssji.net/2024/06/30/python-cli-backward-compatibility-decorator/" rel="nofollow noopener" target="_blank">decorators</a> before. They are useful to extend the behaviour of a function by composition, without having to change the function itself. But functions aren’t the only object that can be decorated: classes can, too.</p><p>I started investigating this when I had a number of different classes implementing a specific behaviour, and wanted to be able to find a specific one. A simple decorator can be written which will add each decorated class into a list. Finding the desired class is then a simple <code>for</code> loop away.</p><p>tl;dr:</p><ul><li>Classes can be decorated in the same way as functions: the decorator takes the class as an argument, does something to or with it, and returns a class.</li><li>For the stated purpose, it’s not necessary, as class inheritance is better suited, and parent classes natively have a <code>__subclasses__</code> method returning a list of their descendents.</li></ul><p></p><p>For a more concrete example, let’s say we want to have a system that support multiple markup languages (e.g, HTML and Markdown). We want independent classes to support each of the languages, and the ability to find the right class for a given language.</p><p><strong>A handful of markups</strong></p><p>Here’s our simple classes.</p><pre>class HtmlSupport: @classmethod def support(cls, lang): return lang == "html"class MarkdownSupport: @classmethod def support(cls, lang): return lang == "markdown"</pre><p>Thanks to the <code>support</code> method, each class can be interrogated about their support for the given <code>lang</code>.</p><pre>&gt;&gt;&gt; MarkdownSupport.support('markdown')True&gt;&gt;&gt; MarkdownSupport.support('html')False</pre><p>But how to find the right support class out of all the existing implementations? We don’t even know what all the implementations are! Now… If we had a list, it would be neater</p><pre>implementations = [ HtmlSupport, MarkdownSupport,]def find_class(lang): for imp in implementations: if imp.support(lang): return imp </pre><p>This is a good start.</p><pre>&gt;&gt;&gt; find_class('html')&lt;class 'decorate.HtmlSupport'&gt;&gt;&gt;&gt; find_class('json')&gt;&gt;&gt;</pre><p><strong>A few markups more</strong></p><p>One issue with this approach is that it needs the <code>implementations</code> list to be explicitely maintained: every new implementation needs to be added to that list, wherever it might be (other source file, other module, …). This is not very nice. Instead, we could offer a function to add new implementations to the list dynamically.</p><pre>implementations = []def add_to_implementation(klass): implementations.append(klass) return klass </pre><p>We can then use this function when we declare new classes.</p><pre>class RestructuredTextSupport: @classmethod def support(cls, lang): return lang == "restructuredtext"add_to_implementation(RestructuredTextSupport)</pre><p>And each class added in this way will be present in the <code>implementations</code> list.</p><pre>&gt;&gt;&gt; implementations[&lt;class '__main__.RestructuredTextSupport'&gt;]</pre><p><strong>Decorators (at last)!</strong></p><p>But hold on. We are calling a method within a file which declare a class? Mixing declaration and instructions is not very nice. Could we do better? This is where decorators come into play. Like <a href="https://en.wikipedia.org/wiki/Le_Bourgeois_gentilhomme" rel="nofollow noopener" target="_blank">M. Jourdain</a>, it turns out we already had one, but we didn’t know about it.</p><pre>@add_to_implementationclass DokuWikiSupport: @classmethod def support(cls, lang): return lang == "dokuwiki"</pre><p>We called it more declaratively, but the outcome is the same.</p><pre>&gt;&gt;&gt; implementations[&lt;class '__main__.RestructuredTextSupport'&gt;, &lt;class '__main__.DokuWikiSupport'&gt;]</pre><p>One important point of note is that our <code>add_to_implementations</code> function returns a class. If it didn’t, the class would still be added correctly to our list of implementations, but it would not be available in local namespace.</p><pre>&gt;&gt;&gt; def half_decorate(cls):... implementations.append(cls)... &gt;&gt;&gt; @half_decorate... class Bob:... pass... &gt;&gt;&gt; implementations[&lt;class '__main__.RestructuredTextSupport'&gt;, &lt;class '__main__.DokuWikiSupport'&gt;, &lt;class '__main__.Bob'&gt;]&gt;&gt;&gt; Bob()Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt;TypeError: 'NoneType' object is not callable</pre><p>In any case, we are now able to declare all our implementations via our decorator. I renamed it to simply <code>implementation</code> for legibility. I’ve also expanded the decorator a bit so it would actually modify the returned class, by adding a <code>decorated</code> method, as a way to demonstrate that the main purpose of decorating still works.</p><pre># decorate.pyimplementations = []def implementation(klass): implementations.append(klass) def decorated(): return True klass.decorated = decorated return klass@implementationclass DokuWikiSupport: @classmethod def support(cls, lang): return lang == "dokuwiki"@implementationclass HtmlSupport: @classmethod def support(cls, lang): return lang == "html"@implementationclass MarkdownSupport: @classmethod def support(cls, lang): return lang == "markdown"class RestructuredTextSupport: @classmethod def support(cls, lang): return lang == "restructuredtext"def find_class(lang): for imp in implementations: if imp.support(lang): return imp </pre><p>And we can finally find our the right class for the right purpose.</p><pre>&gt;&gt;&gt; &lt;class 'decorate.DokuWikiSupport'&gt;&gt;&gt;&gt; find_class('html')&lt;class 'decorate.HtmlSupport'&gt;&gt;&gt;&gt; find_class('txt')&gt;&gt;&gt; &gt;&gt;&gt; find_class('markdown').decorated()True</pre><p><strong>With better design, none of this is necessary</strong></p><p>So, at this point I was pretty happy with myself, and I had solved my problem. But something was bothering me. All those classes implement the same method, so this is screaming for some object orientation, with a nice abstract class.</p><pre># subclasses.pyfrom abc import abstractmethodclass AbstractSupport(): @classmethod @abstractmethod def support(cls, lang): """Return True if this class supports lang"""class HtmlSupport(AbstractSupport): # same body as beforeclass MarkdownSupport(AbstractSupport): # same body as beforeclass RestructuredTextSupport(AbstractSupport): # same body as beforeclass DokuWikiTextSupport(AbstractSupport): # same body as before</pre><p>This is nicer design, but this doesn’t help us find the right implementation just yet. We still need a list to search through. Fortunately, as part of the class hierarchy, Python maintains a list of all the subclasses of each class. It is available from the <code>__subclasses__</code> method.</p><pre>&gt;&gt;&gt; AbstractSupport.__subclasses__()[&lt;class 'subclasses.HtmlSupport'&gt;, &lt;class 'subclasses.MarkdownSupport'&gt;, &lt;class 'subclasses.RestructuredTextSupport'&gt;, &lt;class 'subclasses.DokuWikiSupport'&gt;]</pre><p>So we can do the same dance as before, without having to do anything to maintain the list!</p><pre>def find_class(lang): for imp in AbstractSupport.__subclasses__(): if imp.support(lang): return imp </pre><p>And it all works as needed.</p><pre>&gt;&gt;&gt; find_class("markdown")&lt;class 'subclasses.MarkdownSupport'&gt;&gt;&gt;&gt; find_class("html")&lt;class 'subclasses.HtmlSupport'&gt;&gt;&gt;&gt; find_class("json")&gt;&gt;&gt; </pre><p>We have lost the silly addition of the <code>decorated</code> method along the way, but it was never a requirement in the first place.</p><p>So, here we are. Perhaps I now reach too readily for decorators when simpler and more straightforward solutions exist. They are still useful tools, including on classes, but when dealing with classes, it is probably best to start with what the normal class system offers before trying to reimplement the wheel (albeit a decorated wheel).</p> <p></p><p><strong>Related posts:</strong></p> <a class="" rel="nofollow noopener" href="https://blog.narf.ssji.net/2022/11/22/fun-with-python-decorators/" target="_blank"><span class="">Fun with Python decorators</span></a><a class="" rel="nofollow noopener" href="https://blog.narf.ssji.net/2024/06/30/python-cli-backward-compatibility-decorator/" target="_blank"><span class="">Python CLI backward compatibility decorator</span></a><a class="" rel="nofollow noopener" href="https://blog.narf.ssji.net/2020/04/12/locust-to-load-test-system-performance-under-pressure/" target="_blank"><span class="">How we manipulated Locust to test system performance under pressure</span></a><a class="" rel="nofollow noopener" href="https://blog.narf.ssji.net/2024/05/22/python-objects-as-kwargs/" target="_blank"><span class="">Python objects as kwargs</span></a> <p>Powered by <a href="https://yarpp.com" rel="nofollow noopener" target="_blank">YARPP</a>.</p> <p><a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://blog.narf.ssji.net/tag/decorator/" target="_blank">#decorator</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://blog.narf.ssji.net/tag/python/" target="_blank">#Python</a></p>
Pito Salas<p>Linked is a nice little article exploring closures in Python.<a href="https://salas.com/2024/11/15/python-closures-common-use-cases/#python" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">salas.com/2024/11/15/python-cl</span><span class="invisible">osures-common-use-cases/#python</span></a> <a href="https://ruby.social/tags/closure" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>closure</span></a> <a href="https://ruby.social/tags/function" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>function</span></a> <a href="https://ruby.social/tags/decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>decorator</span></a> <a href="https://ruby.social/tags/programming" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>programming</span></a> <a href="https://ruby.social/tags/explainer" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>explainer</span></a></p>
kalvn<p>Une exploration des possibilités offertes par les décorateurs JavaScript. Ils sont au stage 3 sur 4 de leur standardisation, mais sont déjà supportés par TypeScript et Babel.</p><p>J'ai toujours un peu du mal avec cette façon de faire. Je trouve que ça ajoute une couche de magie un peu trop abstraite et invisibilisée à mon goût, mais j'essayerai de m'y mettre.</p><p>Exploring the Possibilities of Native JavaScript Decorators – Frontend Masters Boost<br><a href="https://frontendmasters.com/blog/exploring-the-possibilities-of-native-javascript-decorators/" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">frontendmasters.com/blog/explo</span><span class="invisible">ring-the-possibilities-of-native-javascript-decorators/</span></a></p><p><a href="https://mastodon.xyz/tags/javascript" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>javascript</span></a> <a href="https://mastodon.xyz/tags/decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>decorator</span></a></p>
Ghostsigns has moved<p>From regular correspondent, Wayne Tanswell Signwriter, the many and varied services of E.F. Andrews, Felixstowe, Suffolk.</p><p>E.F. Andrews<br>Decorator, Plumber &amp; Sanitary Engineer<br>Building &amp; General Repairs<br>Rathbone Furnishing Stores</p><p>136 Hamilton Rd, Felixstowe IP11<br>Streetview: <a href="https://maps.app.goo.gl/6amaGByQ7Q16QzFY7" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">maps.app.goo.gl/6amaGByQ7Q16Qz</span><span class="invisible">FY7</span></a></p><p>Photo: Wayne Tanswell, <a href="http://waynetanswell-signwriter.co.uk/" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">http://</span><span class="ellipsis">waynetanswell-signwriter.co.uk</span><span class="invisible">/</span></a></p><p><a href="https://mastodon.social/tags/ghostsigns" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ghostsigns</span></a> <a href="https://mastodon.social/tags/felixstowe" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>felixstowe</span></a> <a href="https://mastodon.social/tags/suffolk" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>suffolk</span></a> <a href="https://mastodon.social/tags/decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>decorator</span></a> <a href="https://mastodon.social/tags/plumber" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>plumber</span></a></p>
Olivier Mehani<p>New blog post: Python CLI backward compatibility decorator</p><p>Click sometimes introduces too much coupling between the CLI and the underlying Python functions. It is possible to break this coupling using dedicated decorators, so we can refactor the Python code as needed withouth breaking the existing CLI usage.</p><p><a href="https://blog.narf.ssji.net/2024/06/30/python-cli-backward-compatibility-decorator/" class="" rel="nofollow noopener" target="_blank">https://blog.narf.ssji.net/2024/06/30/python-cli-backward-compatibility-decorator/</a></p><p><a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://blog.narf.ssji.net/tag/click/" target="_blank">#Click</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://blog.narf.ssji.net/tag/decorator/" target="_blank">#decorator</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://blog.narf.ssji.net/tag/python/" target="_blank">#Python</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://blog.narf.ssji.net/category/code/" target="_blank">#code</a> <a rel="nofollow noopener" class="hashtag u-tag u-category" href="https://blog.narf.ssji.net/category/tip/" target="_blank">#tip</a></p>
Cyrille Pontvieux<p><span class="h-card" translate="no"><a href="https://hachyderm.io/@nedbat" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>nedbat</span></a></span> Very funny usage of <a href="https://piaille.fr/tags/python" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>python</span></a> <a href="https://piaille.fr/tags/decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>decorator</span></a> !</p>
Habr<p>Замыкания и декораторы в Python: часть 2 — декораторы</p><p>Уважаемые читатели, рад вас приветствовать в новой статье. Этот материал является продолжением предыдущей публикации , посвященной замыканиям. В данной части обзора мы углубимся в тему декораторов. Эта статья написана в первую очередь для тех, кто только начинает свой путь в программировании или начал изучать Python. Потому здесь я не буду рассматривать декораторы классов, чтобы сделать материал более доступным для новичков. Тем не менее, для тех, кто изучит данную статью, не составит труда разобраться в декораторах классов, так как они не имеют существенных отличий от рассматриваемых здесь декораторов функций.</p><p><a href="https://habr.com/ru/articles/800239/" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="">habr.com/ru/articles/800239/</span><span class="invisible"></span></a></p><p><a href="https://zhub.link/tags/python" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>python</span></a> <a href="https://zhub.link/tags/%D0%B4%D0%B5%D0%BA%D0%BE%D1%80%D0%B0%D1%82%D0%BE%D1%80%D1%8B" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>декораторы</span></a> <a href="https://zhub.link/tags/decorator" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>decorator</span></a></p>
Moved to Mastodon, See BelowThis is nice; a laminate of some sort coming off the doors to reveal the hand-painted sign beneath.<br> <br> The sign was visible in this form for a few years, until it was painted over in the recent redecoration/refurbishment of the building at 36 Park Road, Nottingham—work that likely *wasn't* carried by H. Wiltshire &amp; Sons Ltd. Apart from the date of establishment (1905) given on the sign, I've not found out anything more about the firm itself.<br> <br> You can trace the sign's recent history via google streetview, including the coming away of the right side of the laminate some time between 2012–14: <a href="https://maps.app.goo.gl/EZUnRxG8WncDAxyV6" rel="nofollow noopener" target="_blank">https://maps.app.goo.gl/EZUnRxG8WncDAxyV6</a>.<br> <br> Photo and location details kindly shared by Carmen Palmer.<br> <br> <a href="https://pixelfed.social/discover/tags/ghostsigns?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#ghostsigns</a> <a href="https://pixelfed.social/discover/tags/ghostsign?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#ghostsign</a> <a href="https://pixelfed.social/discover/tags/lenton?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#lenton</a> <a href="https://pixelfed.social/discover/tags/nottingham?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#nottingham</a> <a href="https://pixelfed.social/discover/tags/notts?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#notts</a> <a href="https://pixelfed.social/discover/tags/door?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#door</a> <a href="https://pixelfed.social/discover/tags/doors?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#doors</a> <a href="https://pixelfed.social/discover/tags/wiltshire?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#wiltshire</a> <a href="https://pixelfed.social/discover/tags/builder?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#builder</a> <a href="https://pixelfed.social/discover/tags/decorator?src=hash" class="u-url hashtag" rel="nofollow noopener" target="_blank">#decorator</a>