Re: [Edu-sig] python versus __python__

2005-10-26 Thread Scott David Daniels
Beni Cherniavsky wrote: On Mon, 2005-10-24 at 20:24 -0700, Scott David Daniels wrote: Of course, the proper way to compare object identity is not the __low_level__ `id()` function but the ``is`` operator: (math.pi + 1.0) is (29. / 7.) False int('99') is int('99') # small integer

Re: [Edu-sig] python versus __python__

2005-10-25 Thread Beni Cherniavsky
On Mon, 2005-10-24 at 20:24 -0700, Scott David Daniels wrote: With CPython, expressions, once used and dereferenced, recycle their objects. If you don't hold a reference to the value created by calculating the log of pi, it will get recycled once id is done with is arg. The available storage

Re: [Edu-sig] python versus __python__

2005-10-23 Thread Kirby Urner
Kirby PS: since you've been studying subclassing primitive types using __new__, maybe you could show us a user-defined floating point type that reports two numbers equal if their absolute value difference is less than e. Anyone? Like this I guess: class Fuzzy(float): tol =

Re: [Edu-sig] python versus __python__

2005-10-23 Thread Scott David Daniels
Kirby Urner wrote: Kirby PS: since you've been studying subclassing primitive types using __new__, maybe you could show us a user-defined floating point type that reports two numbers equal if their absolute value difference is less than e. Anyone? Fuzzy redone a breath: class Fuzzy(float):

Re: [Edu-sig] python versus __python__

2005-10-23 Thread Kirby Urner
Here's the problem: Your notion of equality is not transitive. That's tough -- it invalidates the assumptions of the float type (and all basic types). Also, you didn't tweak hash, so a dictionary with these things in them would not find entries that turn out to be equal. --Scott David

Re: [Edu-sig] python versus __python__

2005-10-23 Thread Scott David Daniels
Arthur wrote: Scott David Daniels wrote: ... Getting one's arms around all the practical implications of these issues related to mutable, immutable - understanding when one should want to retain object identity, and when one should want to break it, the full implications of these

[Edu-sig] python versus __python__

2005-10-21 Thread Kirby Urner
Going into my new presentation manager materials (perhaps using the same Pygame engine I used at OSCON, but as a general purpose module, i.e. not tied up in that specific content) is the distinction between two kinds of Python: Python and __Python__. You really get to a new level with Python