[issue10410] Is iterable a container type?

2010-11-14 Thread INADA Naoki

INADA Naoki songofaca...@gmail.com added the comment:

 Likewise, and objects of any classes you define
 with an __iter__() or __getitem__() method. is
 wrong because __getitem__ method is not relate to
 iterable

 That wording is correct.  Sequences are automatically
 iterable even if they don't define __iter__.  For example:

Wow, thank you!

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10410
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10410] Is iterable a container type?

2010-11-13 Thread INADA Naoki

New submission from INADA Naoki songofaca...@gmail.com:

In http://docs.python.org/release/2.6.6/glossary.html, iterable is described 
as
A container object capable of returning its members one at a time.
Is it correct? Is stream object like file a container type?

Container ABC requires only __contains__ abstract method. I think file
is iterable but is not container.

Likewise, and objects of any classes you define with an __iter__() or
__getitem__() method. is wrong because __getitem__ method is not relate to
iterable.

--
assignee: d...@python
components: Documentation
messages: 121152
nosy: d...@python, naoki
priority: normal
severity: normal
status: open
title: Is iterable a container type?
versions: Python 2.6, Python 2.7, Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10410
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10410] Is iterable a container type?

2010-11-13 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
assignee: d...@python - rhettinger
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10410
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10410] Is iterable a container type?

2010-11-13 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

 iterable is described as A container object 
 capable of returning its members one at a time.

That wording is confusing.  I'll fix it.

 Likewise, and objects of any classes you define 
 with an __iter__() or __getitem__() method. is 
 wrong because __getitem__ method is not relate to
 iterable

That wording is correct.  Sequences are automatically
iterable even if they don't define __iter__.  For example:

 class A:
... def __getitem__(self, i):
... if i  10:
... raise IndexError(i)
... return i * 100

 list(A())
[0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]

If you're curious, the details are in the PyObject_GetIter() function in 
http://svn.python.org/view/python/branches/release27-maint/Objects/abstract.c?view=markup
 .

--
priority: normal - low

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10410
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10410] Is iterable a container type?

2010-11-13 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Removed the incorrect container reference.
See r86463.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10410
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com