[Python-Dev] Classes with ordered namespaces (original) (raw)

Ethan Furman ethan at stoneleaf.us
Thu Jun 27 17:35:38 CEST 2013


On 06/27/2013 08:18 AM, Eric Snow wrote:

On Thu, Jun 27, 2013 at 2:48 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

I think the main concern I would have is whether other implementations are happy they can provide a suitable ordered dictionary for class namespace execution.

It's also worth considering what would have to happen for dynamically created types where the namespace passed in wasn't ordered. Good points. In either case there is no definition order available. I'm okay with that. Would it be better to represent that as None (and the attribute is always defined) or by having the attribute undefined? I'd rather always have the attribute, but I expect the significantly simpler solution is to leave the attribute undefined when definition order is not available. So I'd go with the latter.

So in Python space the options are either:

if some_class.__definition_order__ is not None:

or

if getattr(some_class, '__definition_order__', None) is not None:

?

Seems like always defined would be easier.

-- Ethan



More information about the Python-Dev mailing list