[Edu-sig] RE: Goofing with Groups
Kirby Urner
pdx4d@teleport.com
Sat, 27 Jan 2001 09:18:34 -0800
At 11:33 AM 01/27/2001 -0600, Arthur_Siegel@rsmi.com wrote:
>>and blew away all my Pythons to go
>>with the newest alpha 2.1.
>
>Couldn't resist a stab at the rich comparison overloading possibilities, I
>suspect.
Exactly right. I'd just written a method to compare two
objects based on the contents of their respective dictionaries
and finding __cmp__ wasn't behaving intuitively for me.
I starting ploughing through the docs looking for something
like __eq__ that'd let me reference == specifically. Then
a few hours later, I was back reading "What's New in 2.1"
and there it was. So you'll find in my final post to the
'goofing' thread:
"I also just this morning downloaded Python 2.1 alpha, which
for the first time allows me to override the symbol ==
(comparison for equality) specifically, and this allows
me to further improve the readability/intuitiveness of
the source code.
So now the dialog looks like this (more like a standard text
book on group theory, permutations chapter):
>>> from clubhouse import *
>>> p1 = S(10) # random permutation of integers 1...10
>>> p2 = S(10)
>>> p3 = S(10) # note: I changed class name from P to S
>>> p1
[(10, 3, 2, 6, 5, 8, 4, 1), (9, 7)]
>>> p1.order() # the order of p1
8
>>> p1**8 # p1**p1.order() = identity element
[]
<<SNIP>>"
>Looking forward to it myself.
>
>ART
Yes, I haven't tried all the new features yet, even the
main ones.
I've built up quite a little nest of mathish utilities.
A year ago I'd have never been able to write a post which
included info like this (shared that with some math
teachers last night):
sqrt(2) = 1.41421356237309504880168872420969+-2
941664/665857 = 1.414213562371500+-1
77227930/54608393 = 1.41421356237309528592+-2
519435045698/367296043199 = 1.414213562373095048801693965672+-1
Kirby