Two classes problem

Caleb Hattingh caleb1 at telkomsa.net
Wed Feb 2 23:43:06 EST 2005


Steven, thanks for your help once again :)

> so you could write the code like:
>
> test = 'first'
> class aclass:
>      def __init__(self, value):
>          mod = __import__(__name__)
>          mod.test = value

This is sweet.  I really like this technique for manipulating module-scope  
identifiers (from within a class or function).

> To the OP:
>
> In general, this seems like a bad organization strategy for your code.  
> What is your actual use case?

Agreed.  It is an interesting intellectual exercise, but there is surely a  
better way of controlling access to 'test' in the OP's post.

thx
Caleb



More information about the Python-list mailing list