[Python-ideas] anonymous object support

Guido van Rossum guido at python.org
Tue Jul 26 04:42:46 CEST 2011


On Mon, Jul 25, 2011 at 7:30 PM, Herman Sheremetyev <herman at swebpage.com> wrote:
> On Tue, Jul 26, 2011 at 9:18 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> <snip>
>> There is absolutely zero reason to add additional complexity to the
>> language core or the standard library for such a niche (and
>> questionable) use case when a simple wrapper function around type can
>> do the job.
>
> As you yourself pointed out, the complexity is already there in the
> core language hiding in a single line of API description to the type()
> function. It's already there to be used, but provides very little
> documentation and an API that is sure to baffle anyone that comes
> across code that uses it.
>
> To reiterate, I am proposing improving the type() API to provide some
> reasonable defaults while retaining backwards compatibility.

Can you summarize the proposal for those who didn't follow the thread
blow-by-blow? Your first message proposed keyword arguments to
object(), which can't fly because object() creates objects without a
__dict__. Now you suddenly seem to have switched to adding more
complexity to type(). But what exactly?

> In other
> words, making an *existing* difficult-to-use API into an intuitive
> one.
>
> FWIW, I think the type() function is not really a great choice for
> making classes on the fly. But if that's what we have to use then
> let's at least make it a little more user-friendly.

So you are proposing to make an undesirable API more user-friendly.
Isn't that creating an attractive nuisance?

-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list