On Tue, May 15, 2012 at 3:25 AM, Christian Heimes wrote:
> Code explains more than words. I've created two examples that some issues.
>
> Mutable values break dicts as you won't be able to retrieve the same
> object again:
Sure, you'll get no argument from me on that. I was more interested
in th
On Monday, May 14, 2012 8:35:36 PM UTC-5, alex23 wrote:
> It looks like this has changed between Python 2 and 3:
>
> "If a class does not define an __eq__() method it should not define a
> __hash__() operation either; if it defines __eq__() but not
> __hash__(), its instances will not be usable as
Am 15.05.2012 07:27, schrieb Ian Kelly:
> Why? I can't see any purpose in implementing __eq__ this way, but I
> don't see how it's "broken" (assuming that __hash__ is actually
> implemented somehow and doesn't just raise TypeError). The
> requirement is that if two objects compare equal, then the
On Tue, May 15, 2012 at 3:27 PM, Ian Kelly wrote:
> Why? I can't see any purpose in implementing __eq__ this way, but I
> don't see how it's "broken" (assuming that __hash__ is actually
> implemented somehow and doesn't just raise TypeError). The
> requirement is that if two objects compare equa
On Mon, May 14, 2012 at 7:50 PM, Christian Heimes wrote:
> Am 13.05.2012 21:11, schrieb Bob Grommes:
>> Noob alert: writing my first Python class library.
>>
>> I have a straightforward class called Utility that lives in Utility.py.
>>
>> I'm trying to get a handle on best practices for fleshing o
Am 13.05.2012 21:11, schrieb Bob Grommes:
> Noob alert: writing my first Python class library.
>
> I have a straightforward class called Utility that lives in Utility.py.
>
> I'm trying to get a handle on best practices for fleshing out a library. As
> such, I've done the following for starters
On May 14, 5:11 am, Bob Grommes wrote:
> Obviously there is some sort of default implementation of __hash__()
> at work and my implementation of _eq_() has somehow broken it.
> Can anyone explain what's going on?
It looks like this has changed between Python 2 and 3:
"If a class does not define
On 05/14/2012 07:38 PM, Chris Kaynor wrote:
> On Sun, May 13, 2012 at 12:11 PM, Bob Grommes wrote:
>>
>>
>> The rule is that, if two objects return different results from
>> __hash__, they should never compare equal. The opposite rule also
>> holds true: if two objects compare equal, they should
On Sun, May 13, 2012 at 12:11 PM, Bob Grommes wrote:
> Noob alert: writing my first Python class library.
>
> I have a straightforward class called Utility that lives in Utility.py.
>
> I'm trying to get a handle on best practices for fleshing out a library. As
> such, I've done the following fo
On Sun, May 13, 2012 at 12:11 PM, Bob Grommes wrote:
> Noob alert: writing my first Python class library.
>
> I have a straightforward class called Utility that lives in Utility.py.
>
> I'm trying to get a handle on best practices for fleshing out a library. As
> such, I've done the following fo
Noob alert: writing my first Python class library.
I have a straightforward class called Utility that lives in Utility.py.
I'm trying to get a handle on best practices for fleshing out a library. As
such, I've done the following for starters:
def __str__(self):
return str(type(self))
#
11 matches
Mail list logo