def __new__(cls, *args, **kwargs):
        """ Creation of a Parsed object from a LexToken, other Parsed of compatible type or string,
            if a string is passed it will be parsed and checked for compatibility with this Parsed type """

        debug = kwargs.get('debug', verbose())
        # type checking
        data = None
        if args :
            if len(args) == 1:
                data = args[0]
            else :
                data = tuple(args)

        # some data (when initializing from single arg) can define the type of Parsed object to be created
        ptype = None
        if data is None :
            # only authorize Empty to be built without arguments
            ptype = 'Empty'
        elif isinstance(data, lex.LexToken) :
            ptype = kwargs.get('type', data.type)
        elif isinstance(data, Parsed) :
            ptype = data.__class__
        # can override type with the keyword 'type'
        ptype=kwargs.get('type', ptype)

        if (cls is Parsed or cls is Token) : #issubclass(cls, Token) ):
            if ptype is not None :
                if verbose():
                    print "__new__ called on Parsed/Token %s with type %r" % (cls.__name__, ptype)
                newcls = Parsed.classes.get(ptype, None)
                # can only specify an existing subclass of cls
                if newcls is None :
                    raise TypeError, "Type %s does not correspond to any existing Parsed sub-class (%s does not exist)" % (ptype, cls.__name__  )
                else :
                    clsname = newcls.__name__
                if not issubclass(newcls, cls) :
                    raise TypeError, "Type %s would create a class %s that is not a sub-class of the class %s that __new__ was called on" % (ptype, clsname, cls.__name__)
            else :
                raise TypeError, (cls.__name__) % "Class %s is an abstract class and can't be created directly, you must specify a valid sub-type"
        else :
            if verbose():
                print "__new__ called on explicit class %s" % (cls.__name__)
            clsname = cls.__name__
            newcls = cls

        # print "Creating new instance of Parsed class: %r" % newcls

        # process arguments and build, check arguments compatibility with that type
        pos = None
        sub = []
        valid = False
        value = data

        #if debug : print "VALUE1", value, repr(value)

        # special case for LexToken
        if isinstance(data, lex.LexToken) :
            if issubclass(newcls, Token) :
                # from a unique lex Token, do not check if also creating a Token
                sub = []
                pos = data.lexpos
                value = data.value
                valid = True
            else :
                # build a Token from it
                value = Token(data.value, ptype=data.type, pos=data.pos)

        if data is None :
            # Tokens can have default value to allow initialization without arguments
            try :
                value = newcls.default()
                valid = True
            except :
                valid = False
        elif isinstance(data, newcls) :
            #if debug : print "IS INSTANCE", data, repr(data)
            # from a similar class, copy it
            sub = data.sub
            pos = data.pos
            valid = data.isValid()
            value = unicode(data)
        elif newcls.accepts(data) :
            #if debug : print "ACCEPTS", data, repr(data)
            # from a compatible Parsed sub class, build the sub list from it
            sub.append(data)
            pos = data.pos
            valid = data.isValid()
            value = unicode(data)
        elif isSequence(data) and not isinstance(data, basestring):
            # building from sub parts, must be of the same type and in class _accepts
            # TODO : use yacc own rules for accepts
            if data :
                valid = True
                p = 0
                for arg in data :
                    # converts LexTokens directly
                    if isinstance(arg, lex.LexToken) :
                        a = Token(arg.value, ptype=arg.type, pos=data.pos)
                    else :
                        a = arg
                    # now check if it's a suitable sub-part or derived class
                    if isinstance(a, newcls) :
                        sub += a.sub
                    elif newcls.accepts(a) :
                        sub.append(a)
                    else :
                        valid = False
                        break
                value = u"".join(map(unicode, data))
                if valid :
                    pos = sub[0].pos
                else :
                    sub = []
            else :
                value = ''
        else :
            if debug : print "REPARSE", data, repr(data)
            # reparse unless it's a Token we already know the type of
            value = unicode(data)
            if issubclass(newcls, Token) and newcls is not Token :
                sub = []
                pos = 0
                valid = True
            else :
                valid = False

        # parse if necessary
        if valid :
            # print "No reparsing necessary for a resulting value %s (%r)" % (value, value)
            strvalue = unicode(value)
        elif isinstance(value, basestring) :
            if debug :
                print "%s: Will need to reparse value %r" % (clsname, value)
            newcls.classparserbuild(debug=debug)
            if debug : print "VALUE", value, type(value)
            result = newcls.classparse(value, debug=debug)
            if debug : print "RESULT", result, type(result), isinstance(result, newcls)
            if result is not None and isinstance(result, newcls) :
                strvalue = unicode(result)
                valid = result._valid
                sub = result._sub
                pos = result._pos
                if debug : print "SUB", sub
            else :
                strvalue = ''
                valid = False
        else :
            raise TypeError, "invalid argument(s) %r, cannot be parsed to create a Parsed object of type %s" % (value, clsname)

        if valid :
            # create a unicode object with appropriate string value
            newobj =  super(Parsed, cls).__new__(newcls)
            newobj._name = strvalue
            #if debug: print "NAME", newobj, type(newobj), sub#, inspect.getmro(newobj)
            # set instance attributes
            newobj._sub = tuple(sub)
            newobj._valid = valid
            # override for pos
            pos = kwargs.get('pos', pos)
            if pos is not None :
                pos += kwargs.get('offset', 0)

            if pos is None or (isinstance(pos, int) and pos>=0) :
                newobj._pos = pos
            else :
                raise ValueError, "A Parsed pos can only be None or an unsigned int, %r invalid" % pos

        return newobj
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.5/pymel/util/objectParser.py/Parsed.__new__/swapped operands of `%`