I don't understand this syntax error

Antoon Pardon apardon at forel.vub.ac.be
Mon Jan 19 05:34:02 EST 2009


I'm probably looking right over it, but for the moment
I'm stumped. Can someone explain what is wrong. I'm running
python 2.5.2 here

This is the code:

class vslice(object):

  def __init__(self, fun):
    self.fun = fun

  def __getitem__(self, inx):
    if not isinstance(inx, tuple):
      inx = inx,
    return self.fun(*inx)

@vslice
class IdSet(object):
  def __init__(self, *args):
    self.lst = [(sl.start, sl.stop) for sl in args]

  def __contains__(self, item):
    for low, high in self.lst:
      if low <= item < high:
        return True
    return False

  def __str__(self):
    return '[' + ', '.join('%d:%d' % sl for sl in self.lst) + ']'

#IdSet = vslice(IdSet)

idset = IdSet[1:3, 6:9]

print idset

for i in xrange(10):
  print i, i in idset


This is the error I get:

  File "vslice.py", line 12
    class IdSet(object):
        ^
SyntaxError: invalid syntax




More information about the Python-list mailing list