Paolino paolo_veronelli at
Sun Jul 31 11:14:56 CEST 2005

While it's not so bad we can bind names in the module namespace, (ex 
writing  scripts ?) ,writing modules is someway bound to not polluting 
that namespace (really IMO).

For non-functions we can use 'class' :

class ns:

but writing a function there triggers the binding to 'self' behaviour.

The straight solution is @staticmethod

class ns:
   def gulp(*args):

Another solution is via metaclass

class namespaceMeta(type):
   def __init__(cls,*more):
     ## wrap all methods with staticmethod()
class namespace:

class ns(namespace):
   def gulp(*args):pass

This solution makes me think the keyword 'namespace' is missing:

namespace ns:
   def gulp(*args):

Solutions and comments appreciated.

Regards Paolino

Yahoo! Messenger: chiamate gratuite in tutto il mondo

More information about the Python-list mailing list