Confusion about iterator types

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Aug 14 16:08:14 EDT 2001


12 Aug 2001 17:06:46 +0200, Martin von Loewis <loewis at informatik.hu-berlin.de> pisze:

> So in general, the __name__ of a type is only roughly related to
> the name to which it is bound in the types module.

At least it tries to be similar to the name under which it's available
in builtins, if it is available. There are some inconsistencies though:

>>> 1 .__add__
<method-wrapper object at 0x8138878>
>>> type(1 .__add__)
<type 'method-wrapper'>
>>> int.__add__
<slot wrapper '__add__' of 'int' objects>
>>> type(int.__add__)
<type 'wrapper_descriptor'>

Note hyphens and underscores.

> If you can point to an actual problem that the current name causes,
> you should make it a bug report.

The reason I would like type names and their reprs to be consistent
is that there are several new types in Python 2.1a. It's not easy
to find out how the complex machinery works - good and consistent
terminology should help a bit.

Especially as there are several "parallel families": values and their
types, things and their iterators, things and their descriptors, things
and their wrappers, or whatever - I don't understand the details.
There are a dozen objects with the string "method" in their repr.
It's all confusing. Maybe some nice diagrams with parallel lines or
at least tables would help...

>>   TypeError: object is not callable: <callable-iterator object at 00B6D10C>

Wonderful error message :-)

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list