This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Decorator to prevent base class methods from being called directly.


from virtualmethod import virtualmethod

class Base(object):
    def my_virtual_method(self):
        print "This is a virtual method. Call me from a subclass!"

class A(Base):

class B(Base):
    def my_virtual_method(self):
        print "I went ahead and implemented my own version."

base = Base()
a = A()
b = B()

-> This is a virtual method. Call me from a subclass!

-> I went ahead and implemented my own version.

-> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "virtualmethod/", line 11, in __call__
    raise TypeError("Virtual method %s must be called from a subclass." % self.__name__)
TypeError: Virtual method my_virtual_method must be called from a subclass.


@virtualmethod works with @classmethod and @staticmethod, but must be declared first, i.e.:

def my_virtual_class_method(cls):


Thanks to Patrick Hensley for his input, and to Denis Ryzhkov for his method_decorator module.

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
virtualmethod-0.0.1.tar.gz (3.5 kB) Copy SHA256 Checksum SHA256 Source Jul 14, 2011

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting