Re: Usage of the __and__ method
- From: Peter Otten <__peter__@xxxxxx>
- Date: Thu, 31 May 2007 07:45:26 +0200
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-ridable or not?
You cannot customize the logical 'and'. The __and__() method is used to
implement the binary and '&'. Change your code to
r = p & q
print r.print_name()
Peter
.
- References:
- Usage of the __and__ method
- From: theju
- Usage of the __and__ method
- Prev by Date: Re: trouble with wxPython intro
- Next by Date: Re: Usage of the __and__ method
- Previous by thread: Usage of the __and__ method
- Next by thread: Re: Usage of the __and__ method
- Index(es):