Circular Class Logic

half.italian at gmail.com half.italian at gmail.com
Thu Mar 15 14:55:08 EDT 2007


> Just initialize Folder at module level - see below.
> -- Paul
>
> class Disk(Folder):
>     def __init__(self,driveLetter):
>         super(Disk,self).__init__(driveLetter+":/")

What is going on there?  Is it just explicitly calling the super's
init function?  How is that really different from this:

class Disk(Folder):
  def __init__(self,driveLetter):
    Folder.Folder.__init__(self.path) # ???  Being that Folder is the
superclass?

I'd like to be able to use the shared Disk objects in any class that
is a subclass of Data.  Will the above method still make the Disk
objects available in File.py?  Also, what if the classes are in
different modules.

I'll try to experiment with it this afternoon.  I'm using more
information than just the drive letter.  What if the user wants to
find out the unc path to the share given the drive letter, or copy a
file to the local disk that is not a system disk that has the most
available space on it, or wants to mount or unmount a network drive.

pause...

I'm trying to justify why the Folders/Files really need the drive info
beyond just the paths and I'm having a hard time.  I even just tried
to give an example of how it would be used, and couldn't.  It seems to
make sense on a gut level, but maybe it's just as usefull on it's
own.  There's definitely justification for having Disks be a subclass
of Folder, but not necessarily for there to be an instance of it
available within the classes.  All that kind of work will be external
to the class.

I think I'll backtrace and keep it separate.  Thanks for letting me
think it through.

~Sean




More information about the Python-list mailing list