total idiot question: +=, .=, etc...
thantos at brimstone.mecha
Thu Jun 24 05:25:28 CEST 1999
On 23 Jun 1999 20:56:41 -0500, Neel Krishnaswami <neelk at brick.cswv.com> wrote:
>It's just that writing self.__class__ is so *ugly*! Everything else
>in Python is beautiful, too, which makes this stand out even more.
Er, that could be because you're doing it wrong? Try:
me.x = 9
def setX(me, val):
me.x = val
>>> y = Foo()
If you /really/ want to go frobbing around with the value that all
instances of the class inherit from, instance.__class__.slot is likely
a /great/ way of pointing out to the reader you're doing something
funky (in that classes are usually thought of as immutable, despite
the reality). The 'unsightly' nature of the construct makes it clear
you're doing something unasthetic.
Alexander Williams (thantos at gw.total-web.net)
"In the end ... Oblivion Always Wins."
More information about the Python-list