[Python-ideas] object construction (was: Re: ML Style Pattern Matching for Python)
ncoghlan at gmail.com
Mon Dec 20 04:18:52 CET 2010
On Mon, Dec 20, 2010 at 6:44 AM, spir <denis.spir at gmail.com> wrote:
> On Sun, 19 Dec 2010 19:52:28 +0100
> Eike Welk <eike.welk at gmx.net> wrote:
>> My positive attitude towards this syntax comes from the only weakness that
>> Python IMHO has: You can't easily see which data attributes an instance has.
>> This information is hidden in __init__, and sometimes elsewhere.
> Rather commonly elsewhere, I guess.
>> I think a
>> mechanism like slots should be the norm, and dynamism the exception.
> I wish we could put in front place the set of intended data attributes, including ones w/o defaults and optional ones. Even better, instanciation with the same param names would automagically set those attributes.
These days, a nice solution to that problem is to define a named tuple
and inherit from it (see the 3.2 version of urllib.parse for a number
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas