[Python-ideas] anonymous object support

Herman Sheremetyev herman at swebpage.com
Tue Jul 26 04:30:51 CEST 2011


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. 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.

-Herman



More information about the Python-ideas mailing list