Overloading the ">>" operator in Python 2.2.1

Andy Elvey andy.elvey at paradise.net.nz
Thu Sep 12 04:22:07 EDT 2002


Hi all .
   I'm using Python 2.2.1 under Win98.  I'm doing some experimenting with
parsing, and as part of that, I'm trying to overload the right-shift
operator (>>) so that I can use it as follows (testing against a sequence
that I read in) -
  a >> b   would mean  "a is followed by b" .
   So,  you could have a function like seqtest("string_to_test" ,
"foo">>"bar" ) , and that function would return true or false, depending on
whether foo was followed by bar.
 (  I know it's possible to use regexes for this,  but being able to create
a sequence-testing operator like this would be useful .)
    Many thanks in advance ......








More information about the Python-list mailing list