Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: Python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.087 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.00; 'class,': 0.07; 'completeness': 0.07; 'try:': 0.07; '"a"': 0.09; 'behave': 0.09; 'construed': 0.09; 'currently,': 0.09; 'def': 0.10; 'buy,': 0.16; 'copy(self):': 0.16; 'solicitation': 0.16; 'instance': 0.17; '>>>': 0.18; 'define': 0.20; 'to:name:python-list@python.org': 0.20; 'trying': 0.21; 'purposes': 0.23; 'statement': 0.23; '----': 0.27; 'right.': 0.27; 'accuracy': 0.27; 'reflect': 0.27; 'statements': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; '(including': 0.30; 'law.': 0.30; 'code': 0.31; 'point': 0.31; 'comments': 0.33; 'material': 0.33; 'profit': 0.33; 'substantial': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; "can't": 0.34; 'self': 0.34; 'thanks': 0.34; 'but': 0.36; 'wanted': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'data': 0.37; 'received:10': 0.38; 'advice': 0.39; 'instead': 0.39; 'performance': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'materials': 0.61; 'received:network': 0.61; 'received:216': 0.62; 'interest': 0.62; 'necessarily': 0.63; 'skip:n 10': 0.63; 'information': 0.63; 'offering': 0.64; 'results': 0.65; 'management': 0.65; 'notified': 0.65; 'offer': 0.65; 'subject': 0.66; 'reliance': 0.66; 'investment': 0.67; 'fund': 0.67; 'income': 0.67; 'contact': 0.68; 'funds': 0.78; 'disclosure,': 0.78; "'test'": 0.84; 'comparable': 0.84; 'investor': 0.93 X-Env-Sender: pradipto.banerjee@adainvestments.com X-Msg-Ref: server-3.tower-160.messagelabs.com!1350395525!11769206!4 X-Originating-IP: [216.166.12.97] X-StarScan-Received: X-StarScan-Version: 6.6.1.3; banners=-,-,- X-VirusChecked: Checked From: Pradipto Banerjee To: "Python-list@python.org" Date: Tue, 16 Oct 2012 08:51:46 -0500 Subject: overriding equals operation Thread-Topic: overriding equals operation Thread-Index: Ac2rpWHfJk6oKsEAROefKNATxvpDJQ== Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: AJh4 ALxa BrXQ CoAg Eauv GEkg GFM6 GOtL G5/Z H2RY Jhal KaWo Ka0W Kety LlUr L/q/; 1; cAB5AHQAaABvAG4ALQBsAGkAcwB0AEAAcAB5AHQAaABvAG4ALgBvAHIAZwA=; Sosha1_v1; 7; {50C73C6E-758F-4CCA-9127-72AEE5041A33}; cAByAGEAZABpAHAAdABvAC4AYgBhAG4AZQByAGoAZQBlAEAAYQBkAGEAaQBuAHYAZQBzAHQAbQBlAG4AdABzAC4AYwBvAG0A; Tue, 16 Oct 2012 13:51:46 GMT; bwB2AGUAcgByAGkAZABpAG4AZwAgAGUAcQB1AGEAbABzACAAbwBwAGUAcgBhAHQAaQBvAG4A x-cr-puzzleid: {50C73C6E-758F-4CCA-9127-72AEE5041A33} acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 66 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350395930 news.xs4all.nl 6850 [2001:888:2000:d::a6]:45251 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31402 I am trying to define class, where if I use a statement a =3D b, then inste= ad of "a" pointing to the same instance as "b", it should point to a copy o= f "b", but I can't get it right. Currently, I have the following: ---- class myclass(object): def __init__(self, name=3D'') self.name =3D name def copy(self): newvar =3D myclass(self.name) return newvar def __eq__(self, other): if instance(other, myclass): return self =3D=3D other.copy() return NotImplemented ---- Now if I try: >>> a=3Dmyclass() >>> a.name =3D 'test' >>> b=3Da >>> b.name 'test' >>> b.name =3D 'test2' >>> a.name 'test2' I wanted b=3Da to make a new copy of "a", but then when I assigned b.name = =3D 'test2', even a.name became 'test2'. How can I rectify my code to make the __eq__() behave like copy()? Thanks This communication is for informational purposes only. It is not intended = to be, nor should it be construed or used as, financial, legal, tax or inve= stment advice or an offer to sell, or a solicitation of any offer to buy, a= n interest in any fund advised by Ada Investment Management LP, the Investm= ent advisor. Any offer or solicitation of an investment in any of the Fund= s may be made only by delivery of such Funds confidential offering material= s to authorized prospective investors. An investment in any of the Funds i= s not suitable for all investors. No representation is made that the Funds= will or are likely to achieve their objectives, or that any investor will = or is likely to achieve results comparable to those shown, or will make any= profit at all or will be able to avoid incurring substantial losses. Perf= ormance results are net of applicable fees, are unaudited and reflect reinv= estment of income and profits. Past performance is no guarantee of future = results. All financial data and other information are not warranted as to c= ompleteness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of = Ada Investment Management LP and its affiliates. This transmission may cont= ain information that is confidential, legally privileged, and/or exempt fro= m disclosure under applicable law. If you are not the intended recipient, y= ou are hereby notified that any disclosure, copying, distribution, or use o= f the information contained herein (including any reliance thereon) is stri= ctly prohibited. If you received this transmission in error, please immedia= tely contact the sender and destroy the material in its entirety, whether i= n electronic or hard copy format.