[vtk-developers] New vtk packages; suggestions reqd. for other modules

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Tue Oct 9 02:56:41 EDT 2001


hi,

>>>>> "DG" == David Gobbi <dgobbi at irus.rri.ca> writes:

    DG> Hi Prabhu, There is another alternative for the namespace
    DG> separation, although it is a little more complicated.  Also,
    DG> it would allow 'from vtk import *' to load everything, but it
    DG> would not allow 'import vtk' to import everything.

Yes, this kind of approach is what Dan was talking about earlier.

    DG> Like I said, a little ugly, but it 1) allows each module to be
    DG> loaded individually, i.e. "import vtk.common" will not cause
    DG> all modules to be silently loaded 2) puts everything in the
    DG> 'vtk' namespace 3) assuming that the __all__ variable can be
    DG> constructed properly (maybe as part of the build process?),
    DG> then no special tricks will be needed for error reporting for
    DG> optional modules 4) allows "from vtk import *" to load
    DG> everything

Why I dont like this approach:

  (1) A normal python developer would expect the following behaviour.
  
	import A.B

	x = A.B.some_class()
      
  and *not*

	import A.B

	x = A.some_class()

  (2) Also, IMHO it is cleaner to have vtk.__init__.py load everything
  silently than have to have subpackage modules insert things into
  their parent packages' namespace.

    DG> but it would be necessary to have a 'everything' or 'all'
    DG> module to load everthing into the vtk namespace withough
    DG> specifying individual package names:

    DG> import vtk.everything

    DG> so it still doesn't seem ideal.

Yes, this is a problem.  So it looks like moving the package structure
to a different directory is the cleanest solution ATM.  This way we
can do:

    import vtk 
    from vtkpkg.gui.tk import RenderWidget
    a = vtk.vtkSomeClass()
    r = RenderWidget()

    # or
    import vtkpkg.common
    a = vtkpkg.common.vtkSomeCommonClass()

etc.  All completely cleanly without any hacks or non-standard
behaviour.  Besides vtkpkg isnt too long a name to type (at any rate
it is shorter than vtkpython :).

Other possible names instead of vtkpkg

  (1) vtkpy
  (2) pyvtk
  (3) vtkPy
  (4) VTK
  (5) Vtk
  (6) pkgvtk

    DG> Thanks a lot for your work on this, btw.  I wish that I had
    DG> more time to participate in the discussions.

We all wish that too. :)

prabhu



More information about the vtk-developers mailing list