Popular recipes tagged "methods" but not "attributes"http://code.activestate.com/recipes/tags/methods-attributes/2017-04-20T23:34:50-07:00ActiveState Code RecipesImplementing class-based callbacks in Python (Python)
2017-04-20T23:34:50-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580788-implementing-class-based-callbacks-in-python/
<p style="color: grey">
Python
recipe 580788
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/callbacks/">callbacks</a>, <a href="/recipes/tags/classes/">classes</a>, <a href="/recipes/tags/functions/">functions</a>, <a href="/recipes/tags/methods/">methods</a>, <a href="/recipes/tags/objects/">objects</a>, <a href="/recipes/tags/programming/">programming</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>This is a follow-on to this recently posted recipe:</p>
<p>Implementing function-based callbacks in Python:
<a href="https://code.activestate.com/recipes/580787-implementing-function-based-callbacks-in-python/?in=user-4173351" rel="nofollow">https://code.activestate.com/recipes/580787-implementing-function-based-callbacks-in-python/?in=user-4173351</a></p>
<p>This new recipe shows how to create and use callbacks in Python, using classes with methods, instead of plain functions, as was done in the recipe linked above. All other points such as reasons and benefits for using callbacks, are more or less the same as mentioned in the previous recipe, except that class instances can carry state around, so to that extent, the two approaches are different.</p>
<p><a href="https://jugad2.blogspot.in/2017/04/python-callbacks-using-classes-and.html" rel="nofollow">https://jugad2.blogspot.in/2017/04/python-callbacks-using-classes-and.html</a></p>
Python method chaining examples (Python)
2016-02-25T19:40:33-08:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/580616-python-method-chaining-examples/
<p style="color: grey">
Python
recipe 580616
by <a href="/recipes/users/4173351/">Vasudev Ram</a>
(<a href="/recipes/tags/chaining/">chaining</a>, <a href="/recipes/tags/methods/">methods</a>, <a href="/recipes/tags/object/">object</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>This recipe shows a few examples of doing method chaining in Python.</p>
Object snoop - experiment with Python special methods (Python)
2010-09-05T17:54:50-07:00Wai Yip Tunghttp://code.activestate.com/recipes/users/2382677/http://code.activestate.com/recipes/577383-object-snoop-experiment-with-python-special-method/
<p style="color: grey">
Python
recipe 577383
by <a href="/recipes/users/2382677/">Wai Yip Tung</a>
(<a href="/recipes/tags/metaprogramming/">metaprogramming</a>, <a href="/recipes/tags/methods/">methods</a>, <a href="/recipes/tags/object/">object</a>).
</p>
<p>In Python, classes can define their own behavior with respect to language operators. For example, if a class defines __getitem__(), then x[i], where x is an instance of the clas, will be execute by a call to x.__getitem__(i).</p>
<p>While Python has an extensive documentation on the special methods, reading a specification may not be the best way to reveal the intricate details. <strong>object_snoop</strong> allows user to observe how Python expressions and statements are translated into special method calls. object_snoop defines most special methods. It simple print a trace and returns a fixed but sensible result. Users are invited to build complex expressions to experiment how Python special methods work.</p>
Method Caching (Python)
2010-07-27T20:26:08-07:00Danillo Souzahttp://code.activestate.com/recipes/users/4174445/http://code.activestate.com/recipes/577338-method-caching/
<p style="color: grey">
Python
recipe 577338
by <a href="/recipes/users/4174445/">Danillo Souza</a>
(<a href="/recipes/tags/cache/">cache</a>, <a href="/recipes/tags/methods/">methods</a>, <a href="/recipes/tags/python/">python</a>).
</p>
<p>Save each set of parameters with your respective return value in cache.</p>