[Adam Monsen]
> The following code uses the % operator to print possibly unitialized
> data attributes:
> 8<
> class J:
> name = ''
> value = ''
> def __str__(self):
> vals = self.__class__.__dict__
> vals.update(self.__di
Leif K-Brooks wrote:
> This will update the class's attributes with instance attributes
> when str() is called, which probably isn't what you want.
[...]
Yikes, you're right! Well, I figured out a modification to my original
__str__ code that works for old and new-style classes which doesn't
overw
Adam Monsen wrote:
> class J:
> name = ''
> value = ''
> def __str__(self):
> vals = self.__class__.__dict__
> vals.update(self.__dict__)
> return 'name="%(name)s" value="%(value)s' % vals
This will update the class's attributes with instance attributes when
str
The following code uses the % operator to print possibly unitialized
data attributes:
8<
class J:
name = ''
value = ''
def __str__(self):
vals = self.__class__.__dict__
vals.update(self.__dict__)
return 'name="%(nam