[Python-Dev] FW: if-else with '|' operator - beginner's question/problem

Tim Peters tim.one@home.com
Wed, 8 Aug 2001 14:13:56 -0400

What a fascinating newbie confusion!  It surprised and tickled me.

FYI, in Icon this kind of thing "just works".  e1 | e2 | ... | en is "a
generator" there too, and acts like the Python

def g():
    for x in e1:
        yield x
    for x in e2:
        yield x
    for x in en:
        yield en

Then the expression y1 == y2 generates the cross-product of the y1 and y2
sequences, succeeding in the end iff some pair of generated values compares

No, I'm not suggesting Python do that too <wink>.  It's more in the way of
noting that no matter *how* odd a question looks to you, some peoples'
brains are so wired that it's hard for them to view it otherwise.

finally-understanding-vi-users<wink>-ly y'rs  - tim

-----Original Message-----
From: python-list-admin@python.org
Sent: Wednesday, August 08, 2001 1:26 PM
To: python-list@python.org
Subject: if-else with '|' operator - beginner's question/problem

Hi there, I wonder if someone could possibly tell me what is wrong with
the following statement. I'm extremely embarrased to ask but here

>>>  if (fname[1] == 'a'|'e'|'i'|'o'|'u'):

Traceback (innermost last):
  File "<pyshell#46>", line 1, in ?
    if (fname[1] == 'a'|'e'|'i'|'o'|'u'):
TypeError: bad operand type(s) for |

fname[1] gives 'e'

Thanks very much in advance!