Question about inheritance...

Ron Adam rrr at ronadam.com
Sun Oct 23 00:52:19 EDT 2005


KraftDiner wrote:

> Well here is a rough sketch of my code...
> This is giving my two problems.
> 
> 1) TypeError: super() argument 1 must be type, not classobj
> 2) I want to be sure the the draw code calls the inherited classes
> outline and not its own...
> 
> class Shape:
> 	def __init__(self):
> 		pass
> 	def render(self):
> 		print self.__class___
> 		self.outline()
> 	def outline(self):
> 		pass
> 
> class Rect(Shape):
> 	def __init__(self):
> 		super(self.__class__, self).__init__()
> 	def render(self):
> 		super(self.__class__, self).draw()
> 	def outline(self):
> 		print 'outline' + self.__class__

I think Alex probably answered your question.  I'm still trying to 
figure out how use inheritance effectively myself.


Are you using this as an way to learn Python or do you want to use 
Python to render images?


What I'm trying to do in relation to this is to build a "small" subset 
of the SVG standard in tkinter. It looks like the SVG standard is going 
to be very popular graphic format on the web, hand held devices, and as 
a general graphics format.

	http://www.w3.org/TR/SVG/

Python doesn't have good SVG support built in without importing a third 
party library, and the ones that are available need other libraries, 
etc...  They don't really support using SVG directly in programs.  So 
I'm experimenting with emplimenting some of the SVG functionality in 
Tkinter for drawing icons in dialog box's.  It's an experiment at the 
moment, but I'd like to see it grow into something more.

It doesn't need to be exactly like it, but the closer it is to the way 
the SVG standard works, the better.  That would make it easier to use 
some 'simple' existing SVG images, and easier to create SVG files as 
well, as it closes the gap between the canvas object and the VGA standard.

Anyway, I'm more than willing to get involved in a group to do this if 
anyone is interested and also thinks it may be worth while.

Cheers,
    Ron














More information about the Python-list mailing list