itertools.flatten()? and copying generators/iterators.
Francis Avila
francisgavila at yahoo.com
Tue Oct 28 07:07:43 EST 2003
More information about the Python-list mailing list
Tue Oct 28 07:07:43 EST 2003
- Previous message (by thread): How to use python-mcrypt?
- Next message (by thread): itertools.flatten()? and copying generators/iterators.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Alex Martelli" <aleax at aleax.it> wrote in message news:Tesnb.57573$e5.2124916 at news1.tin.it... > Peter Otten wrote: > ... > > def keepstrings(seq): > > if isinstance(seq, basestring): > > raise TypeError > > return iter(seq) > ... > > The above handles strings in a way that is nonintrusive on client code. > > Yes, very nice. I'd make keepstrings the default (one RARELY wants > to treat strings as nonatomic) AND replace the typetest with an > attempt to do a seq+'' (if it doesn't raise, seq ain't a string), > but that's just me:-). > > Alex > try: seq+'' seems more expensive. Is it just to handle the case where someone makes a string-alike that doesn't derive from str? (Actually, I guess that's about all pre-2.2 code.) Is it expensive enough to even matter? -- Francis Avila
- Previous message (by thread): How to use python-mcrypt?
- Next message (by thread): itertools.flatten()? and copying generators/iterators.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list