473,414 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Is this an Bug in python 2.3??

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
Jul 18 '05 #1
1 1155
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)

iD8DBQFAyhsMJd01MZaTXX0RAtpKAJ9JiVBF9gsYmc5iJodvhA u4wKHt4wCfeNgt
6TGJ9/YQWLlghZSfH1A4UcI=
=4TmR
-----END PGP SIGNATURE-----

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.