other python ideas

Laurent POINTAL pointal at lure.u-psud.fr
Thu May 25 13:07:20 CEST 2000


On Wed, 24 May 2000 08:18:03 +1000, "Arnold deVos"
<adv at langdale.com.au> wrote:

>: The real problem is that a module exports all the symbols it has imported.
>: This sometimes creates a chain of unintentional dependencies between
>: modules - a bit like the sort of thing that happens with .h files in C.
>: 
>: e.g. if I forgot to import string, my code might still work because I import
>: x that imports y that imports string.  No amount of testing can reveal this
>: error.  Later someone changes the implementation of y, removing string.
>: Later still, I run my previously tested code and the error is unexpectedly
>: (confusingly) revealed.

In our modules, we use the following syntax to avoid publication of
imported symbols (copied from... I dont remember which Python source):

import string
_string = string
del string


And we always prefix string operation functions by _string.

A+

Laurent.

---
Laurent POINTAL - CNRS/LURE - Service Informatique Experiences
Tel/fax: 01 64 46 82 80 / 01 64 46 41 48
email  : pointal at lure.u-psud.fr  ou  lpointal at planete.net 



More information about the Python-list mailing list