Re: Usage of the __and__ method

2007-05-31 Thread theju
Thank you folks for reminding me that the logical AND cannot be over- ridden and that the __and__ method represents the bit-wise AND operation. Thank You Thejaswi Puthraya http://thejuhyd.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Usage of the __and__ method

2007-05-30 Thread attn . steven . kuo
On May 30, 10:11 pm, theju <[EMAIL PROTECTED]> wrote: > Hello all, > I've two objects (both instances of a class called Person) and I want > to use the __and__ method and print the combined attributes of the two > instances. > > To be precise, here is my code > > class Person: > def __init_

Re: Usage of the __and__ method

2007-05-30 Thread Peter Otten
theju wrote: > I've two objects (both instances of a class called Person) and I want > to use the __and__ method and print the combined attributes of the two > instances. > r = p and q > print r.print_name() > The above output in both cases is giving me a doubt if __and__ method > is over-ridabl

Re: Usage of the __and__ method

2007-05-30 Thread rishi pathak
This works perfectly well. class Person: def __init__(self,name): self.name = name def print_name(self): print self.name def __and__(self,other): print "self.name : ",self.name print "other.name : ",other.name self.name = '%s AND %s' %(self.name,other.name)

Re: Usage of the __and__ method

2007-05-30 Thread rishi pathak
class Person: def __init__(self,name): self.name = name def print_name(self): print self.name def __and__(self,other): print "self.name : ",self.name print "other.name : ",other.name self.name = '%s AND %s' %(self.name,other.name) return self.name p = Per

Usage of the __and__ method

2007-05-30 Thread theju
Hello all, I've two objects (both instances of a class called Person) and I want to use the __and__ method and print the combined attributes of the two instances. To be precise, here is my code class Person: def __init__(self,name): self.name = name def print_name(self):