test if a subclass inherits a superclass method
Littlefield, Tyler
tyler at tysdomain.com
Sat Sep 10 10:08:28 EDT 2011
On 9/10/2011 5:58 AM, Kayode Odeyemi wrote:
> Hello,
>
> I'm testing Python's class abstractness and inheritance. Since
> interface doesn't exist, I will
> like to test how to have access to a superclass method from a subclass
> without necessary
> invoking or overriding the superclass method in its subclass.
>
> >>> class Equipment(object):
> ... def fault():
> ... return "fault"
> ...
> >>> Equipment().__class__
> <class '__main__.Equipment'>
> >>> class Vehicle(Equipment):
> ... # Find out here if Vehicle has access to fault
>
> I want to know whether Vehicle has access to Equipment's fault() method.
> Just want to know if it's there(that a vehicle can also develop a fault).
>
> I know I can override it, but I want to know if I can use it directly
> without overriding it.
Perhaps this helps:
http://stackoverflow.com/questions/610883/how-to-know-if-an-object-has-an-attribute-in-python
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
--
Take care,
Ty
Web: http://tds-solutions.net
The Aspen project: a light-weight barebones mud engine
http://code.google.com/p/aspenmud
Sent from my toaster.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110910/9ae7cd0e/attachment-0001.html>
More information about the Python-list
mailing list