Re: Magic?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mk

    Re: Magic?

    However, it appears that somehow this object prints the value of 's'
    attribute without me setting any specific methods to do that:
    >
    >>astr = lstr('abcdef')
    >>astr
    'abcdef'
    >>astr.swapcase ()
    'ABCDEF'
    Correction: it doesn't really get the value from _s attribute:
    >>astr = lstr('abcdef')
    >>astr.s
    'abcdef'
    >>astr.s='xyzzy '
    >>astr
    'abcdef'
    >>astr.s
    'xyzzy'


    So my updated question is where does this lstr() instance keep the
    original value ('abcdef')? It obviously has smth to do with inheriting
    after str class, but I don't get the details of the mechanism.

Working...