[Python-ideas] Re: Thoughts about implementing object-compare in unittest package?

2020-07-27 Thread Ethan Furman
On 7/27/20 5:00 PM, Christopher Barker wrote: I guess this is the part I find confusing: when (and why) does __eq__ play a role? __eq__ is the final authority on whether two objects are equal. The default __eq__ punts and used identity. On Mon, Jul 27, 2020 at 12:01 PM Ethan Furman

[Python-ideas] Re: Thoughts about implementing object-compare in unittest package?

2020-07-27 Thread Christopher Barker
I guess this is the part I find confusing: when (and why) does __eq__ play a role? On Mon, Jul 27, 2020 at 12:01 PM Ethan Furman wrote: > Equal objects must have equal hashes. > Objects that compare equal must have hashes that compare equal. > OK got it. However, not all objects with the

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-27 Thread Robert Collins
On Mon, 27 Jul 2020 at 23:24, Vinay Sharma wrote: > > Hi, Thanks for replying. > > > One thing that is worth thinking about is the safety of the API that > > is put together. A memory segment plus a separate detached semaphore > > or mutex can be used to build a safe API, but is not itself a safe

[Python-ideas] Re: default parameter in fuctions to clean up flow

2020-07-27 Thread Richard Damon
On 7/27/20 10:01 AM, Peter Moore wrote: > I have had a long standing unanswered question on on stackoverflow: is it > possible to pass a function to a default parameter so that you could do in > essence things like this. > > def time_diff(target_time, curr_time= lambda : datetime.now() ): >

[Python-ideas] Re: Thoughts about implementing object-compare in unittest package?

2020-07-27 Thread Ethan Furman
On 7/27/20 11:15 AM, Christopher Barker wrote: On Sun, Jul 26, 2020 at 8:25 PM Guido van Rossum wrote: In fact, defining `__hash__` as returning the constant `42` is better, because it is fine if two objects that *don't* compare equal still have the same hash value (but not the other way

[Python-ideas] Re: Thoughts about implementing object-compare in unittest package?

2020-07-27 Thread Christopher Barker
On Sun, Jul 26, 2020 at 8:25 PM Guido van Rossum wrote: > The only reason I can think of why you are so resistant to this would be > due to poor development practices, e.g. adding tests long after the "main" > code has already been deployed, or having a separate team write tests. > and even

[Python-ideas] Re: default parameter in fuctions to clean up flow

2020-07-27 Thread Dominik Vilsmeier
On 27.07.20 16:01, Peter Moore wrote: I have had a long standing unanswered question on on stackoverflow: is it possible to pass a function to a default parameter so that you could do in essence things like this. def time_diff(target_time, curr_time= lambda : datetime.now() ): return

[Python-ideas] Re: default parameter in fuctions to clean up flow

2020-07-27 Thread Peter Moore
I should add to this (as I cant edit my post) that please note it is not a constant we are adding. Its a value that will change each time you call the function. It could be a GUID or rand number too. In this case its the current time. ___ Python-ideas

[Python-ideas] default parameter in fuctions to clean up flow

2020-07-27 Thread Peter Moore
I have had a long standing unanswered question on on stackoverflow: is it possible to pass a function to a default parameter so that you could do in essence things like this. def time_diff(target_time, curr_time= lambda : datetime.now() ): return curr_time - target_time this would be an

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-27 Thread Vinay Sharma via Python-ideas
Hi, Thanks for replying. > One thing that is worth thinking about is the safety of the API that > is put together. A memory segment plus a separate detached semaphore > or mutex can be used to build a safe API, but is not itself a safe > API. Agreed. That’s why I am more inclined to the second

[Python-ideas] Re: How to prevent shared memory from being corrupted ?

2020-07-27 Thread Robert Collins
On Sun, 26 Jul 2020 at 19:11, Vinay Sharma via Python-ideas wrote: > > Problem: > Currently, let’s say I create a shared_memory segment using > mulitprocessing.shared_memory.SharedMemory in Process 1 and open the same in > Process 2. > Then, I try to write some data to the shared memory segment