Getting rid of "self."

Nick Coghlan ncoghlan at iinet.net.au
Fri Jan 7 16:20:31 CET 2005


BJörn Lindqvist wrote:
> So I'm asking here if someone
> knows a better way, maybe using decorators or metaclasses or other
> black magic?

Wait for Python 3k when this will work:

class c:
   def __init__(self):
     with self:
       .x = 1
       .y = 2
       .hi = "Hi there!"

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list