Setting a Global Default for class construction?

Lao Coon laocoon at eudoramail.com
Fri Jan 31 23:35:41 CET 2003


Josh English <english at spiritone.com> wrote in 
news:b1erj009ok at enews3.newsguy.com:

> Here is the code that I am struggling with in a Python module:
> 
> _Thing = "it"
> 
> def SetThing(s):
>      global _Thing
>      _Thing = str(s)
> 
> class NewThing:
>      def __init__(self,thing=_Thing):
>           self.Thing = _Thing

Here you're always setting self.Thing to "it"
you want "self.Thing = thing"..




More information about the Python-list mailing list