Newbye and packages

Toni post_to_usenet at Hotmail.com
Mon Jun 11 17:07:25 CEST 2001


Hi,

(I have searched for this in the FAQ and groups, but have found no clue)

Imagine I want to build a package hierarchy of the kind:

image_file
    gif_file
    png_file
    ...

with associated classes:

class image_file:
   "Base class for image files hierarchy"

class gif_file(image_file):
class png_file(image_file):

each on an independent package/module, so that it is easy to add more
classes as needed

I have tried several approaches, but never got to do something like

import image_file.gif_file
a = image_file.gif_file("test.gif")
if (a.transparency()) ....

The reason for having the base image_file class is for coding default
values for uncommon things. For example, if I coded a bmp_file class, I
wouldn't code the transparency() method and let de base class answer
'no'.

What would be the right approach? Ideas welcome

TIA

--
Toni





More information about the Python-list mailing list