Changeset 057e4d3 in git


Ignore:
Timestamp:
Jun 23, 2005, 5:24:01 PM (19 years ago)
Author:
Michael Brickenstein <bricken@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
e25c5effa9b6fa015db14b7bde31ddca40b78786
Parents:
17c7ba38fdfb7e1701605423c601fe8230072950
Message:
*bricken: beautified


git-svn-id: file:///usr/local/Singular/svn/trunk@8390 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/openmathserver/binding.py

    r17c7ba r057e4d3  
    11from objects import OMObjectBase, OMSymbol
    2 from cd import *
    3 from omexceptions import *
     2from cd import OMCD
     3from omexceptions import UnsupportedOperationError
    44from itertools import izip
    55from copy import copy
    6 cdFns1=OMCD("fns1")
    7 lambdasym=OMSymbol("lambda",cdFns1)
     6cdFns1 = OMCD("fns1")
     7lambdasym = OMSymbol("lambda", cdFns1)
    88
    99def islambda(sym):
    10     return lambdasym==sym
     10    return lambdasym == sym
    1111   
    1212class OMBinding(OMObjectBase):
     
    1414       meant so, references do not work correctly because of scopes
    1515       solve this by first evaluation to bounded OMBinding"""
    16     def __init__(self, binder,variables,block):
    17         super(OMBinding,self).__init__()
    18         self.block=block
    19         self.binder=binder
    20         self.variables=variables
    21         self.bounded=False
    22     def evaluate(self,context):
     16    def __init__(self, binder, variables, block):
     17        super(OMBinding, self).__init__()
     18        self.block = block
     19        self.binder = binder
     20        self.variables = variables
     21        self.bounded = False
     22    def evaluate(self, context):
    2323        assert islambda(self.binder)
    2424        if not self.bounded:
    25             mycopy=copy(self)
    26             mycopy.scope=context.scopeFromCurrentScope()
    27             mycopy.bounded=True
     25            mycopy = copy(self)
     26            mycopy.scope = context.scopeFromCurrentScope()
     27            mycopy.bounded = True
    2828            return mycopy
    2929        else:
     
    3131    def bind(self, args):
    3232        #print args, self.variables
    33         assert len(args)==len(self.variables)
    34         varBindings=dict(izip([i.name for i in self.variables],args))
     33        assert len(args) == len(self.variables)
     34        varBindings = dict(izip([i.name for i in self.variables], args))
    3535        self.scope.push(varBindings)
    3636    def unbind(self):
    3737        self.scope.pop()
    3838
    39     def calcErg(self,context):
    40         return context.evaluateInScope(self.block,self.scope)
    41     def __call__(self, context,*args):
     39    def calcErg(self, context):
     40        return context.evaluateInScope(self.block, self.scope)
     41    def __call__(self, context, *args):
    4242        self.bind(args)
    43         erg=self.calcErg(context)
     43        erg = self.calcErg(context)
    4444        self.unbind()
    4545        #print "__call__ erg is", erg
    4646        return erg   
    4747       
    48     XMLtag="OMBIND"
     48    XMLtag = "OMBIND"
    4949    def getChildren(self):
    5050        return [self.binder]+self.variables+[self.block]
Note: See TracChangeset for help on using the changeset viewer.