Strange (?) list comprehension behavior

Peter Hansen peter at engcorp.com
Sun Jul 20 05:59:11 CEST 2003


George Henry wrote:
> 
> class PSILex:
>   ops = ["~", "!", "@", ... "|", "||", ... ]

What are those ...'s ?  You may have left out critical
data for us.

>   ...
>   def __findAtom(self):
>     result = ""
>     ops = [op for op in PSILex.ops if self.text.startswith(op)]
> 
> ... results in a traceback and "TypeError: expected a character buffer
> object." In trying to figure out what was going on, in the Python Shell I
> subsequently tried

Please post the precise traceback, cut and pasted.  If it really said
that, and your subsequent analysis is valid, I think one of your "ops"
is not a string...




More information about the Python-list mailing list