Is this an Bug in python 2.3??

B

Balaji

Hello,

here is the code..

class E:
def __init__(self):

def relationalOperators(self,op,rightOperand):
e=E()
e.operator =op
e.left=self
e.right=rightOperand
def __ge__(self,g1):
return self.relationalOperators('>=',g1)
def __le__(self,g1):
return self.relationalOperators('<=',g1)
class V(E):
""" This is a variable for MPY"""
def __init__(self,domain=Continuous,lb=0,ub=Infinity):
print "V",
self.domain = domain
E.__init__(self)
self.hasVar = True
self.val = None

def __str__(self):
if self.val:
# print "self.val *****"
return str(self.val)
else:
return findRefTo(self) or "MPY Error! Printing unnamed variable."

Now x=V() instance of class variable..

e1=100>=x

no if i say something like this

e1.operator
it returns

'<='

but if i say e1=x>=100

e1.operator

it returns '>='

How do i overcome this ...

Balaji
 
J

Jeff Epler

There doesn't seem to be any bug here.

You may need to read:
http://docs.python.org/ref/customization.html#l2h-184

Just as
a + b
may use a.__add__(b) or b.__radd__(a),
a < b
may use a.__lt__(b) or b.__gt__(a), as described in the language
reference.

If you read this part of the language reference and still think the
behavior is different than the documentation, please follow-up on
the list.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAyhsMJd01MZaTXX0RAtpKAJ9JiVBF9gsYmc5iJodvhAu4wKHt4wCfeNgt
6TGJ9/YQWLlghZSfH1A4UcI=
=4TmR
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top