itertools.flatten()? and copying generators/iterators.
Francis Avila
francisgavila at yahoo.com
Tue Oct 28 08:02:36 EST 2003
"Peter Otten" <__peter__ at web.de> wrote in message
news:bnlp0m$d9l$01$1 at news.t-online.com...
> Francis Avila wrote:
>
> > 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
>
> I you think that the concatenation is costly, as I did when I read your
> remark - it's not:
>
> >>> smartSnakes = "don't rattle"
> >>> smartSnakes is (smartSnakes + "")
> True
>
> Peter
Actually, I meant the exception testing. Isn't Alex suggesting something
like?:
try:
seq+''
except:
seq is not a string
else:
seq is a string
--
Francis Avila
More information about the Python-list
mailing list