Tag : extending
Prototipal heritance and leaving trail of implementations
|January 10, 2013|
|Two ways of extending a class by class methods||Shamaoke||Ruby||extending||
An example which illustrates the ways of extending a class by class methods.
|December 28, 2010|
|PluginManager - Extending Project Functionality By Using Custom Modules/Plugins On The Fly.||AJ. Mayorga||python||extending extensible modules plugin||
This demo shows how you can create and manage your own custom plugins for extending functionality in your Python projects. There are no safety wrappers in this demo for restricting plugins aside from that fact that plugins are run as an extention of a management class which is run in its own instance only receiving data passed to it by the RumModules method, that said security should ideally be applied to the ModuleAPI class, by restricting __builtins__ on eval calls and/or validating plugin content and parameters which can be done by extending the Prepaser Class. For a great recipe/demo of restricting eval call see http://code.activestate.com/recipes/496746.
That aside it was alot of fun to write and use. Enjoy
PS: you will need http://code.activestate.com/recipes/577144/ to import Xceptions
|May 5, 2010|
Change old functions to new -> "From SoQ to jQuery"
|December 11, 2009|
|Find all subclasses of a given class||Gabriel Genellina||python||class extending inheritance plugin subclass subclasses type||
itersubclasses(cls) returns a generator over all subclasses of cls, in depth first order. cls must be a new-style class; old-style classes are not supported.
|November 4, 2009|
|Utility Mill Import||Stephen Chappell||python||extending||
After looking at featurelist.org and noticing that someone wanted to import code stored on Utility Mill, the following code was written as an extension of previous work on automated testing. The original thread can be found at http://featurelist.org/features/details/238 . The code imported by the test at the end of this code can be found at http://utilitymill.com/edit/SPICE/27 & http://utilitymill.com/edit/nysiis/20 . Please note that this is Python 3.0 code importing Python 2.5 code and may not be useful in all contexts that you may wish to use it in. Also, modules stored on Utility Mill may need unconditionally executing code removed first before importing.
|December 29, 2008|
|Easier positional arguments for optparse||Shekhar Tiwatne||python||Easier positional arguments optparse extending||
Many times I find myself write a cli that takes two/more positional arguments. Something like mycp file1 file2 [options] I have to write extra code everytime to show correct usage/hints to user if he invokes command this way mycp file1 Positional arguments are required ones unlike optional arguments.
The solution below lets cli writer add a positional argument so parser can generate usage friendlier to positional args.
Some inspiration: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/573441
|July 14, 2008|
|py3to2 - test/develop/integrate python 3.0 code natively under robust, software-rich python 2.5 environment||kai zhu||python||py3to2 test/develop/integrate python code natively under robust software-rich python environment extending||June 28, 2008|
|Selective cleanup (deletion) of files (based on category and extension) for use by a SABnzbd+ external post-processing script||A B||python||Selective cleanup (deletion) files (based category extension) SABnzbd+ external post-processing script extending post_processing post_processing_script sabnzbd sabnzbdp||
This script clean's up (deletes) files with specific extensions, e.g. .sfv, .nzb, but only for downloads belonging to a particular category.
|June 1, 2008|
|A simple calculator that works with whole numbers written in C/Python.||Nycholas Oliveira e Oliveira||python||simple calculator that works with whole numbers written C/Python. extending||
A simple calculator that works with whole numbers written in C/Python.
The purpose of this implementation is only to show how a simple extension C/Python that can help people who are starting with C/Python.
In this cookbook show the two codes in C, the first is the pure C and the second is the implementation for Python.
I hope this cookbook possar help.
-- Until more and good luck, Nycholas de Oliveira and Oliveira.
|May 16, 2008|
|List wrapper for generators (indexable, subscriptable)||Florian Leitner||python||List wrapper generators (indexable subscriptable) extending||
Similar to <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/523026">Andrew Moffat's recipe</a>, this class takes a generator function as an argument and returns a list object where the generator's items can be accessed by indices (as indices or slices). Only once a certain index value was requested, it actually iterates the generator to that point. See docstrings for more. The values are stored in a Berkeley DB which is created in a temporary file on the fly (it would not need much to modify the code to store in memory if you would prefer that) in such a manner that for any object where id(obj1) == id(obj2) is True, only one entry is stored.
|October 15, 2007|
|Automatic ref-count management in C++ using a smart ptr||Ian Eloff||python||Automatic ref-count management using smart extending||
Managing ref-counting is a complex and error prone business. If you choose C++ to extend or embed Python, you can simply use a modification on std::auto_ptr. Instead of calling delete on the managed pointer, it will decref it.
So now you can do:
auto_py str = PyStr_FromString("Hello World!");
and forget about having to decref it altogether! Just like auto_ptr you can get the PyObject * with get(), release it from managed control with release(), and rebind it with reset(new_ptr). You can also incref it by calling inc(), but be cautious as you can easily create a leak by increfing once to much.
|August 14, 2007|
|Extending socket.socketpair() to work on Windows||Bob Ziuchkovski||python||Extending socket.socketpair() work Windows network||
This recipe wraps socketpair() to provide a standard socket pair on POSIX systems or a pair of connected sockets using ephemeral ports on Windows.
|July 22, 2007|
|subscriptable generator||Andrew Moffat||python||subscriptable generator extending||
let's you define a generator with an internal cache that can be accessed like a list
|July 7, 2007|
|Extending pyunit||Tim Watson||python||Extending pyunit oop||
Extends pyunit with method decorators, allowing the programmer to 'anotate' test methods and expected exceptions, rather than having to adhere to a naming convention.
|April 16, 2007|