[Python-3000] Ambiguity in PEP 3115 and the args to prepare (original) (raw)
Brett Cannon brett at python.org
Sun Sep 2 19:43:34 CEST 2007
- Previous message: [Python-3000] Ambiguity in PEP 3115 and the args to __prepare__
- Next message: [Python-3000] Ambiguity in PEP 3115 and the args to __prepare__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 9/2/07, Guido van Rossum <guido at python.org> wrote:
On 9/2/07, Brett Cannon <brett at python.org> wrote: > PEP 3115 says a metaclass' prepare takes two positional arguments, > name and bases. But the example has it actually accept an arbitrary > number of arguments: name and then everything else is bound to bases. > > Which happens to be true? I'm too tired to even fully trust that I am > reading the PEP correctly, so I am not about to try to write an > example to see which is correct and come up with a coherent rewording > if I am right about what is wrong. =)
I think you're misreading what you think is an example. I'm assuming you're referring to this code: def prepareclass(name, *bases, metaclass=None, **kwargs): if metaclass is None: metaclass = computedefaultmetaclass(bases) prepare = getattr(metaclass, 'prepare', None) if prepare is not None: return prepare(name, bases, **kwargs) else: return dict() This indeed defines a function with a *bases argument, but it is not called prepare! It calls prepare passing it name and bases, i.e. the 2nd argument to prepare is a tuple of bases.
Ah, OK, that is the issue (that and type.prepare takes any arguments and just always returns a new dictionary). So it was the lack of sleep. =)
-Brett
- Previous message: [Python-3000] Ambiguity in PEP 3115 and the args to __prepare__
- Next message: [Python-3000] Ambiguity in PEP 3115 and the args to __prepare__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]