[Python-Dev] itertools.chain should take an iterable ? (original) (raw)
Jack Diederich jack at performancedrivers.com
Thu Sep 1 19:35:19 CEST 2005
- Previous message: [Python-Dev] itertools.chain should take an iterable ?
- Next message: [Python-Dev] itertools.chain should take an iterable ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Sep 01, 2005 at 07:58:40PM +0200, Paolino wrote:
Working on a tree library I've found myself writing itertools.chain(*[child.method() for child in self]). Well this happened after I tried instinctively itertools.chain(child.method() for child in self).
Is there a reason for this signature ?
This is more suited to comp.lang.python
Consider the below examples (and remember that strings are iterable)
import itertools as it list(it.chain('ABC', 'XYZ')) ['A', 'B', 'C', 'X', 'Y', 'Z'] list(it.chain(['ABC', 'XYZ'])) ['ABC', 'XYZ'] list(it.chain(['ABC'], ['XYZ'])) ['ABC', 'XYZ']
Hope that helps,
-jackdied
- Previous message: [Python-Dev] itertools.chain should take an iterable ?
- Next message: [Python-Dev] itertools.chain should take an iterable ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]