Popular recipes tagged "meta:loc=199"http://code.activestate.com/recipes/tags/meta:loc=199/2015-06-29T13:59:38-07:00ActiveState Code RecipesSimple video with ctypes and Xvid (Tkinter,pygame,...) (Python)
2015-06-29T13:59:38-07:00Jiri Justrahttp://code.activestate.com/recipes/users/4192188/http://code.activestate.com/recipes/579073-simple-video-with-ctypes-and-xvid-tkinterpygame/
<p style="color: grey">
Python
recipe 579073
by <a href="/recipes/users/4192188/">Jiri Justra</a>
(<a href="/recipes/tags/ctypes/">ctypes</a>, <a href="/recipes/tags/video/">video</a>, <a href="/recipes/tags/xvid/">xvid</a>).
</p>
<p>This is simple library for playing avi video clips. Videos must be SOUNDLESS (and maybe Xvid encoded wont hurt), to work it properly. I am using it to play intro. It suites good to this purpose, since it can play one clip at a time only.</p>
Decorator and context manager from a single API (Python)
2010-06-27T15:15:01-07:00Michael Foordhttp://code.activestate.com/recipes/users/2183852/http://code.activestate.com/recipes/577273-decorator-and-context-manager-from-a-single-api/
<p style="color: grey">
Python
recipe 577273
by <a href="/recipes/users/2183852/">Michael Foord</a>
(<a href="/recipes/tags/contextmanager/">contextmanager</a>, <a href="/recipes/tags/context_manager/">context_manager</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/decorators/">decorators</a>, <a href="/recipes/tags/with/">with</a>, <a href="/recipes/tags/with_statement/">with_statement</a>).
Revision 12.
</p>
<p>Create objects that act as both context managers <em>and</em> as decorators, and behave the same in both cases.</p>
<p>Works with Python 2.4 - 2.7 and Python 3. The tests require unittest2 or Python 3.2 to run. (And because the tests use the with statement they won't work with Python 2.4.)</p>
<p>Example:</p>
<pre class="prettyprint"><code>from contextdecorator import ContextDecorator
class mycontext(ContextDecorator):
def __init__(self, *args):
"""Normal initialiser"""
def before(self):
"""
Called on entering the with block or starting the decorated function.
If used in a with statement whatever this method returns will be the
context manager.
"""
def after(self, *exc):
"""
Called on exit. Arguments and return value of this method have
the same meaning as the __exit__ method of a normal context
manager.
"""
</code></pre>
<p>Both before and after methods are optional (but providing neither is somewhat pointless). See the tests for more usage examples.</p>
Python FTP Client (Python)
2007-06-21T12:13:54-07:00N Shttp://code.activestate.com/recipes/users/4040791/http://code.activestate.com/recipes/521925-python-ftp-client/
<p style="color: grey">
Python
recipe 521925
by <a href="/recipes/users/4040791/">N S</a>
(<a href="/recipes/tags/web/">web</a>).
</p>
<p>This is a lightweight FTP client. I find it useful for my purposes. You may notice some weird code, but I assure you, it is legitimate. Python was being stubborn, so I had to circumvent some of the rules.</p>
safer serialization of simple python types, part two (Python)
2005-06-13T07:00:35-07:00S Whttp://code.activestate.com/recipes/users/1759688/http://code.activestate.com/recipes/415791-safer-serialization-of-simple-python-types-part-tw/
<p style="color: grey">
Python
recipe 415791
by <a href="/recipes/users/1759688/">S W</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 4.
</p>
<p>This recipe is a reimplemtation of this recipe,</p>
<p><a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/415503" rel="nofollow">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/415503</a></p>
<p>using Python 2.4 decorator syntax.</p>
<p>It also has added support for boolean and unicode types, and a keyword argument (compress=False) for the dumps function, which will compress the string.</p>