charlie at begeistert.org
Fri Aug 3 16:05:23 CEST 2001
Not bad! How about
This would resemble dictionary.has_key(...).
I've just read the whole thread to try and get to grips with it.
"isinstance" and "issubclass" are plain ugly and confusing to read and a
lot of the debate has centred around consistency with the rest of the
language. I suppose it's trying to square the circle which is so
I understand the problem like this: Classes keep lists of their
sub-classes *and* of their instances and "in" is a keyword which checks
for membership in sequences.
guido = GoodProgrammer()
charlie = BadProgrammer()
Is this the right way of thinking about it? If so we could then ask our
classes to list their instances and subclasses and apply membership
tests to them.
>>> ['GoodProgrammer', 'BadProgrammer']
This would then let us test for membership in class instances or
Guido in Programmer.instance()
Guido in GoodProgrammer.instance()
Guido in Programmer.subclass()
Charlie in BadProgrammer.instance()
>>>very much so
I think the syntax might not be correct but this would seem to me to be
a clean way of checking for membership without introduing new key words,
new attributes subclass and instance (or should that be __subclass__,
__instance___?) which are only handles for object counters and "in"
would be preserved as the shorthand for the contains method. Not so sure
how this would apply to the built-ins. Something like this?
>>>x = 4
>>>x in int.instance()
What thinketh yee?
I still don't get generators btw. What does 'yield' do that 'return'
More information about the Python-list