Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>, Ben Finney wrote:
> 
> >     class Human_Sex(str):
> >         def __repr__(self):
> >             repr_str = "%s(name=%s)" % (
> >                 self.__class__.__name__,
> >                 str.__repr__(self)
> >             )
> >             return repr_str
> 
> I'm a bit surprised that `Human_Sex` is subclassing `str`.

So far, the "attribute" classes in this application are just
state-encapsulations, so they might as well subclass 'object'. I
subclassed 'str' to get the constructor and __str__ cheaply (in coding
time). The rest of the baggage of 'str' is rather unnecessary, I
suppose.

-- 
 \    "Anything that is too stupid to be spoken is sung."  -- Voltaire |
  `\                                                                   |
_o__)                                                                  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to