Metaclass for Interface Checking

Category: Python - Miscellaneous

Checks a class definition for required attributes
<br>
To use it, add two lines to your class, __metaclass__=InterfaceChecker and __implements__=[InterfaceName]. The example below generates the following error message:
<br>
InterfaceOmission: ['__delitem__']
<br>
Verifying interfaces for an object becomes trivial. For instance, if you need to validate that variable 'x' implements a minimal sequence interface, verify that: <br>
MinimalSequence in x.__implements__ Date: 15 May, 2012


Debugging

Homepage: http://code.activestate.com/recipes/204349-metaclass-for-interface-checking/?in=lang-python

Developer: Raymond Hettinger

License: Python License

Operating System: Windows

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

Vrode Script Editor is the easy-to-use editor for JavaScript, VBScript, HTML and CSS files.

developer Developer: Vrode Soft
license License: GNU General Public License (GPL)
operating systems Operating System: Windows Vista


Streamlines your authoring and site administration by identifying your server environment and reporting the results directly in your browser.

developer Developer: http://www.craigrichards...
license License: Freeware
operating systems Operating System: All


STLFilt simplifies and/or reformats long-winded C++ error and warning messages, with a focus on STL-related diagnostics (and for MSVC 6, it fully eliminates C4786 warnings and their detritus).

developer Developer: BD Software
license License: Freeware
operating systems Operating System: Windows, Unix, OS X


Jackal is a debug tool written in javascript for client-side javascript debugging.

developer Developer: SourceForge.net
license License: Freeware
operating systems Operating System: All


This script is a simple embedded multiline python interpreter built around raw_input().

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Since Python 2.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


The function printexpr() takes a Python expression, and prints it's value, and the filename and line from which printexpr() is called.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Suppose your application needs to know the relative path from one path to another (say because you want to create a symbolic link, a relative reference in a URL, etc).

developer Developer: Cimarron Taylor
license License: Python License
operating systems Operating System: Windows


Sometimes you want to have a list comprehension refer to itself, but you can't because it isn't bound to a name until after it is fully constructed.

developer Developer: Chris Perkins
license License: Python License
operating systems Operating System: Windows